xeipuuv/gojsonschema

Validate return err on golang 1.19

CharlesQQ opened this issue · 1 comments

As following code example, gojsonschema.Validate return err open file:/Users/momo/go/src/ch/redis-inspector/build.json: no such file or directory, but file /Users/momo/go/src/ch/redis-inspector/build.sh exist

func main() {
	shemaPath := path.Join("file://", "/Users/momo/go/src/ch", "redis-inspector/build.json")
	shemaLoader := gojsonschema.NewReferenceLoader(shemaPath)
	var  input  string =  ""
	dataLoader := gojsonschema.NewGoLoader(input)
	result, err := gojsonschema.Validate(shemaLoader, dataLoader)
	fmt.Println(result, err)
}

it is not a problem with the library: in recent versions of go, you must take file:// out of the path.Join:

"file://" + path.Join("/User....", "redis...")