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/internal/imports: should not use "." in the first component to decide standard library #41118

Closed
linzhp opened this issue Aug 28, 2020 · 2 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@linzhp
Copy link
Contributor

linzhp commented Aug 28, 2020

x/tools/internal/imports uses "." in the first component of import path to decide whether an import is a standard library. This is not reliable as some orgs may prefix generated code with "mock", "proto" etc to keep them separate from regular code.

A more reliable approach is github.com/bazelbuild/bazel-gazelle/language/go.IsStandard.

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

$ go version
go version go1.15 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zplin/Library/Caches/go-build"
GOENV="/Users/zplin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zplin/gocode/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/zplin/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bf/3ympgpy92txgknkb4z30dldh0000gn/T/go-build397579031=/tmp/go-build -gno-record-gcc-switches -fno-common"
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Aug 28, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 28, 2020
@mvdan
Copy link
Member

mvdan commented Aug 28, 2020

I disagree; see #32819. In particular:

Import paths without dots are reserved for the standard library and toolchain.

It's true that this is not well documented yet, but that's why the issue linked above is open.

/cc @bcmills @heschik

@linzhp
Copy link
Contributor Author

linzhp commented Aug 28, 2020

OK. Since this is intentional, I will close this ticket.

@linzhp linzhp closed this as completed Aug 28, 2020
@golang golang locked and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants