-1

I'm playing with GraphQL in Go and I was trying to get gqlgen tool using the familiar go run command.

I was expecting it to retrieve the latest available tag, instead I"m somehow getting a tag which does not seem to exist in the repo at all:

$ go run github.com/99designs/gqlgen version
v0.9.1-dev

I would expect the above to return per the latest tag

v0.13.0

Go version installed on my workstation:

$ go version
go version go1.15.5 darwin/amd64

Anyone has any ideas what's going on?

UPDATE: disabling GOPROXY does not help

UPDATE2: it turns out the version is hardcoded into version.go as you can see here, but even if go run gets the master instead of the latest tag, you'd still expect the output to be 0.13.0-dev as per the master branch Instead I suspect there is some string ordering of versions of tags which orders 0.9.* above 0.1*.*

milosgajdos
  • 851
  • 1
  • 14
  • 32
  • You should not be using `go run` if the versions matter in any way. It’s better to just avoid it altogether. – JimB Nov 14 '20 at 16:48

2 Answers2

0

I think the version command was misconfigured on build, and that v0.9.1-dev was not the tag at build time.

Justin Cormack
  • 1,226
  • 12
  • 8
0

go run does not currently support running a specific version of a binary, but note that there is an accepted Go proposal to add that functionality in a future release of the go command.

As of Go 1.16, you can instead go install the binary at a specific version, and then run that binary from its install location (either $(go env GOBIN) or $(go env GOPATH)/bin).

$ GOBIN=~/bin go install github.com/99designs/gqlgen@latest
$ ~/bin/gqlgen ...
bcmills
  • 4,391
  • 24
  • 34
  • For Go versions through Go 1.16, `go run` runs whatever version is already indicated by the dependencies of the current module. You can identify that version using `go list -f '{{with .Module}}{{.Path}} {{.Version}}{{end}}' github.com/99designs/gqlgen`. – bcmills Feb 17 '21 at 15:13