Skip to content

x/tools/cmd/goimports: does not understand identifiers defined by internal test files #29979

@rogpeppe

Description

@rogpeppe

What version of Go are you using (go version)?

$ go version
go version devel +4b3f04c63b Thu Jan 10 18:15:48 2019 +0000 linux/amd64

As of commit 0a99049, goimports does not seem to consider the local package as a candidate for an external test.

Here's a testscript example that demonstrates the issue:

exec goimports -w a_test.go
cmp a_test.go a_test.go-goimports

-- go.mod --
module example.com/a
-- a_test.go --
package a_test

func TestX() {
	a.X()
	a.Y()
}
-- a.go --
package a

func X() {
}
-- export_test.go --
package a

func Y() {
}
-- a_test.go-goimports --
package a_test

import "example.com/a"

func TestX() {
	a.X()
	a.Y()
}

I would expect running goimports on a.go to add an import of example.com/a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions