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
Milestone

Comments

@linzhp
Copy link
Contributor

@linzhp 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 label Aug 28, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 28, 2020
@mvdan
Copy link
Member

@mvdan 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 linzhp commented Aug 28, 2020

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

@linzhp linzhp closed this Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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