Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/goimports: does not consider "internal" restrictions #15993

fedyakin opened this issue Jun 7, 2016 · 1 comment

x/tools/cmd/goimports: does not consider "internal" restrictions #15993

fedyakin opened this issue Jun 7, 2016 · 1 comment


Copy link

@fedyakin fedyakin commented Jun 7, 2016

  1. What version of Go are you using (go version)?
    go version go1.6 windows/amd64
  2. 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 GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
  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.

package foo

func Bar() {


package foo

func Bar() {

Then create a file that uses the internal package.

package main

func main() {

Finally, run goimports on main.go.

  1. What did you expect to see?
    I expected import "" to be added to main.go. Which foo to choose should have been unambiguous since the other is not importable from package1/main.
  2. What did you see instead?
    goimports added import "". I deleted the import statement and ran goimports several times. The package imported appeared to be random.
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jun 7, 2016
@ianlancetaylor 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 gopherbot added the Tools label Sep 12, 2019
Copy link

@heschik heschik commented Nov 7, 2019

I've seen the code that fixes this, though I don't know when it went in.

@heschik heschik closed this Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.