go: cmd/go: go list reports a mangled ImportPath for a relative path that is not a valid Go package
What version of Go are you using (go version
)?
Using gotip
as of 12/5/2019 because this workflow fails with an error using Go 1.13.4:
$ gotip version go version devel +eeb319a Thu Dec 5 22:16:02 2019 +0000 darwin/amd64
What did you do?
$ mkdir ~/foo && cd $_
$ echo "module github.com/nmiyake/foo" > go.mod
$ gotip list -e -f {{.ImportPath}} .
What did you expect to see?
github.com/nmiyake/foo
What did you see instead?
_/Users/nmiyake/foo
When running with Go 1.13.4, see:
build .: cannot find module for path .
This is likely #35414, which has been fixed on tip.
Further information/context
When a Go file is added to the directory, the output is as expected:
$ echo "package main" > main.go
$ gotip list -e -f {{.ImportPath}} .
github.com/nmiyake/foo
The behavior previously worked as I would expect in GOPATH mode:
$ mkdir $GOPATH/src/github.com/nmiyake/foo && cd $_
$ gotip list -e -f {{.ImportPath}} .
github.com/nmiyake/foo
If the list
command can find the go.mod
file and determine the import path relative to that, it would be helpful if it returned the import path if Go files existed in the directory rather than the _
import path.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (14 by maintainers)
This appears to be fixed by CL 185345: