You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of Go are you using (go version)? go version go1.6 windows/amd64
What operating system and processor architecture are you using (go env)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\dev
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
What did you do?
I created two internal packages with the same name, but in different trees. I was able to reproduce the problem with the following small example. D:\dev\src\github.com\issue\package1\internal\foo\foo.go
package foo
func Bar() {
}
and D:\dev\src\github.com\issue\package2\internal\foo\foo.go
package foo
func Bar() {
}
Then create a file that uses the internal package. D:\dev\src\github.com\issue\package1\main\main.go
package main
func main() {
foo.Bar()
}
Finally, run goimports on main.go.
What did you expect to see?
I expected import "github.com/issue/package1/internal/foo" to be added to main.go. Which foo to choose should have been unambiguous since the other is not importable from package1/main.
What did you see instead?
goimports added import "github.com/issue/package2/internal/foo". I deleted the import statement and ran goimports several times. The package imported appeared to be random.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
x/tools/cmd/goimports: Imports internal packages not under the file's root.
x/tools/cmd/goimports: does not consider "internal" restrictions
Jun 7, 2016
gopherbot
added
the
Tools
This label describes issues relating to any tools in the x/tools repository.
label
Sep 12, 2019
go version
)?go version go1.6 windows/amd64
go env
)?I created two internal packages with the same name, but in different trees. I was able to reproduce the problem with the following small example.
D:\dev\src\github.com\issue\package1\internal\foo\foo.go
and
D:\dev\src\github.com\issue\package2\internal\foo\foo.go
Then create a file that uses the internal package.
D:\dev\src\github.com\issue\package1\main\main.go
Finally, run goimports on main.go.
I expected
import "github.com/issue/package1/internal/foo"
to be added to main.go. Which foo to choose should have been unambiguous since the other is not importable from package1/main.goimports added
import "github.com/issue/package2/internal/foo"
. I deleted the import statement and ran goimports several times. The package imported appeared to be random.The text was updated successfully, but these errors were encountered: