go: cmd/go: `go get` fails when repository ends with `.go`
What version of Go are you using (go version
)?
$ go version go version go1.12 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go envGOARCH=“amd64” GOBIN=“” GOCACHE=“/Users/himitsu/Library/Caches/go-build” GOEXE=“” GOFLAGS=“” GOHOSTARCH=“amd64” GOHOSTOS=“darwin” GOOS=“darwin” GOPATH=“/Users/himitsu/repos/lkjh-dev” GOPROXY=“” GORACE=“” GOROOT=“/usr/local/Cellar/go/1.12/libexec” GOTMPDIR=“” GOTOOLDIR=“/usr/local/Cellar/go/1.12/libexec/pkg/tool/darwin_amd64” GCCGO=“gccgo” CC=“clang” CXX=“clang++” CGO_ENABLED=“1” GOMOD=“” CGO_CFLAGS=“-g -O2” CGO_CPPFLAGS=“” CGO_CXXFLAGS=“-g -O2” CGO_FFLAGS=“-g -O2” CGO_LDFLAGS=“-g -O2” PKG_CONFIG=“pkg-config” GOGCCFLAGS=“-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xl/vzfvbyrs29s3t2mmh15ygmv00000gn/T/go-build506667951=/tmp/go-build -gno-record-gcc-switches -fno-common”
What did you do?
When trying to fetch the latest version or a tag of the NATS Go client as follows, it fails with a no such file or directory
error.
GO111MODULE=on go get github.com/nats-io/nats.go@latest
stat github.com/nats-io/nats.go: no such file or directory
GO111MODULE=on go get github.com/nats-io/nats.go@v1.8.1
stat github.com/nats-io/nats.go: no such file or directory
One workaround for this when using Go 1.12 is to append an extra slash at the end of the repository name and then add the explicit version as follows:
GO111MODULE=on go get github.com/nats-io/nats.go/@latest
...
# Explicit tag version
GO111MODULE=on go get github.com/nats-io/nats.go/@v1.8.0
go: finding github.com/nats-io/nats.go v1.8.0
go: downloading github.com/nats-io/nats.go v1.8.0
go: extracting github.com/nats-io/nats.go v1.8.0
What did you expect to see?
I expected go get
to download the library as follows:
GO111MODULE=on go get github.com/nats-io/nats.go@v1.8.0
go: finding github.com/nats-io/nats.go v1.8.0
go: downloading github.com/nats-io/nats.go v1.8.0
go: extracting github.com/nats-io/nats.go v1.8.0
Or when not specifying a version either, expected for it to download the latest one:
GO111MODULE=on go get github.com/nats-io/nats.go
go: finding github.com/nats-io/nats.go v1.8.1
go: downloading github.com/nats-io/nats.go v1.8.1
go: extracting github.com/nats-io/nats.go v1.8.1
What did you see instead?
GO111MODULE=on go get github.com/nats-io/nats.go@v1.8.0
stat github.com/nats-io/nats.go: no such file or directory
Also when not specifying any version always fail, regardless of trailing slash or not:
GO111MODULE=on go get github.com/nats-io/nats.go/
stat github.com/nats-io/nats.go: no such file or directory
GO111MODULE=on go get github.com/nats-io/nats.go
stat github.com/nats-io/nats.go: no such file or directory
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 30 (12 by maintainers)
Should be out soon enough. Feel free to subscribe to https://github.com/golang/go/issues/34970.
Thanks @jayconrod @bcmills just tried it building Go from master and it works great 🙌 Looking forward to the 1.13.1 release!
It looks like this behavior has worsened in Go 1.13, now it is not possible at all to
go get
the nats module repository:Thanks @letientai299. You should discuss the approach you’ve considered with @bcmills and @jayconrod here, since they’re owners of
cmd/go
behavior, and see what they think.I have a potential concern about it, in that it introduces unpredictable behavior. The same command invocation may act differently depending on whether or not a .go file exists and can be accessed without errors. I’m not sure of a better solution, I just wanted to point out the potential concern.
@dmitshur, I’m still quite new to golang project workflow, so, thanks for the reminder, and please guide me through this second CL.
My fix in above CL is basically trying load patterns ended with
.go
as go files, and if it fails, fall back to loading the patterns as packages.Change https://golang.org/cl/180923 mentions this issue:
cmd/goget: support package ended with '.go'