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
package main
import "fmt"
func main() {
fmt.Println(colornames.Blue)
}
Dockerfile:
FROM golang:1.11
RUN go get golang.org/x/tools/cmd/goimports
WORKDIR /home/example
RUN go mod init example
# Cache golang.org/x/images/colornames and populate go.mod and go.sum.
COPY withImport.go p.go
RUN go run p.go
# Delete the golang.org/x/images/colornames import statement.
COPY withoutImport.go p.go
Then build the docker container and run goimports in it:
$ docker build -t example .
$ docker run example goimports p.go
What did you expect to see?
I expected goimports to find the colornames package, because the package's repo is listed in go.mod and go.sum, and the package itself is in go's cache. (And in the full example where I encountered this in the wild, the package was also imported elsewhere in my project.)
So I expected the output of goimports to look like this:
Both are really "dups" of #24661 which is tracking the fixing of all tools with modules, but I've linked to #27287 as the issue for goimports specifically.
What version of Go are you using (
go version
)?go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?(Though repro instructions are given as a Dockerfile, below)
What did you do?
Here's a minimal Docker example. Place the following three files in an empty directory:
withImport.go:
withoutImport.go:
Dockerfile:
Then build the docker container and run goimports in it:
What did you expect to see?
I expected goimports to find the colornames package, because the package's repo is listed in go.mod and go.sum, and the package itself is in go's cache. (And in the full example where I encountered this in the wild, the package was also imported elsewhere in my project.)
So I expected the output of goimports to look like this:
What did you see instead?
Since
golang.org/x/image/colornames
was not present in my GOPATH, goimports failed to find it:The text was updated successfully, but these errors were encountered: