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/gopls: automatic imports sometimes pick non-optimal modules #60663

Open
andig opened this issue Jun 7, 2023 · 2 comments
Open

x/tools/gopls: automatic imports sometimes pick non-optimal modules #60663

andig opened this issue Jun 7, 2023 · 2 comments
Labels
gopls/imports gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@andig
Copy link
Contributor

andig commented Jun 7, 2023

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

$ go version
go version go1.20.5 darwin/arm64

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="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build1707488893=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.20.5 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.20.5
uname -v: Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103
ProductName:		macOS
ProductVersion:		13.3.1
ProductVersionExtra:	(a)
BuildVersion:		22E772610a
lldb --version: lldb-1403.0.17.64
Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)

What did you do?

  1. Create an application e.g. importing "github.com/coreos/v3/go-oidc/oidc"
  2. Write/tidy the go.mod
  3. Create new Go file in Vscode and try to use the oidc.ScopeOpenID constant

What did you expect to see?

Package "github.com/coreos/v3/go-oidc/oidc" imported by gopls

What did you see instead?

Package "github.com/coreos/go-oidc" imported by gopls

I would have expected the already-imported package to be used, instead gopls seems to pick any package that it might find suitable.

/cc @adonovan

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 7, 2023
@peterldowns
Copy link

Related to this — is it possible to configure the import-suggester to never suggest certain packages? I read the settings documentation and could not find a relevant setting, but I am not confident I'm looking for the right term. Between vscode settings, lsp settings, and the formatter (gofumpt is what I think I'm using?) I also don't know where this setting should exist.

@seankhliao seankhliao changed the title gopls: automatic imports sometimes pick non-optimal modules x/tools/gopls: automatic imports sometimes pick non-optimal modules Jun 10, 2023
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 10, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 10, 2023
@findleyr
Copy link
Contributor

Thanks for the report.

I'm collecting goimports related issues into a gopls/imports label. There are numerous such issues, and I think we need to revisit them holistically.

@suzmue suzmue modified the milestones: Unreleased, gopls/later Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/imports gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants