itchyny / gojq

Pure Go implementation of jq
MIT License
3.3k stars 119 forks source link

Change in behavior between go1.20 and go 1.21 (unable to query document) #234

Closed wizardishungry closed 10 months ago

wizardishungry commented 10 months ago

swagger.json downloaded from https://eastus.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/

$ jq  < swagger.json "."  | wc -l
    8155
$ asdf shell golang 1.20.5  && go run github.com/itchyny/gojq/cmd/gojq  < swagger.json "."  | wc -l
    8155
$ asdf shell golang 1.21.4  && go run github.com/itchyny/gojq/cmd/gojq  < swagger.json "."  | wc -l
       0
$ go run github.com/itchyny/gojq/cmd/gojq -v
gojq 0.12.14 (rev: HEAD/go1.20.5)

Same behavior for other queries. Other JSON works fine.

wader commented 10 months ago

Strange. Seem to work with golang 1.21.4 on macOS

$ uname -a
Darwin C02WW1K9HV2R 22.6.0 Darwin Kernel Version 22.6.0: Wed Oct  4 21:25:26 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_X86_64 x86_64
$ go version
go version go1.21.4 darwin/amd64
$ go run github.com/itchyny/gojq/cmd/gojq < swagger.json . | wc -l
    8155

What does it say if you do

go run github.com/itchyny/gojq/cmd/gojq . swagger.json; echo $?

But i did noticed that the "." should probably be an argument to gojq and not a file to redirect. For me with zsh i get an error if i try to redirect (.: Is a directory)

go run github.com/itchyny/gojq/cmd/gojq  . < swagger.json | wc -l
wizardishungry commented 10 months ago

I'm not sure what was going on. I tried skipping the asdf shim and deleting my mod cache. Finally I just did a clean reinstall of go and that fixed it. Not sure why it was only that particular document, but this is all on me. Thanks and sorry to bother you.

wader commented 10 months ago

No worries, been there :)