-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/imports
Milestone
Description
Go version
go version go1.22.2 darwin/arm64, golang.org/x/tools/gopls v0.15.2
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/jzelinskie/Library/Caches/go-build'
GOENV='/Users/jzelinskie/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/jzelinskie/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/jzelinskie/.local/share/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-L/opt/homebrew/lib'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/y8/7684dpln6fx116tgj4gb_ff00000gn/T/go-build3939956594=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
- Import a module that contains both a v2 and v1 version (e.g.
import "github.com/jzelinskie/cobrautil/v2/cobraotel"
). - Use another package from that module
- Run gopls/goimports to add the missing module
I'm not fully sure these are the minimum steps to reproduce, but I believe so. It might have to do with that's in your module cache, too.
I've had this cause issues in production because it slipped past code review because of how dependent folks are on for import tooling and linters on imports -- humans barely look at them.
What did you see happen?
The v1 module is imported
import (
"github.com/jzelinskie/cobrautil"
"github.com/jzelinskie/cobrautil/v2/cobraotel"
)
What did you expect to see?
The v2 module should be imported because it's already being used:
import (
"github.com/jzelinskie/cobrautil/v2"
"github.com/jzelinskie/cobrautil/v2/cobraotel"
)
Metadata
Metadata
Assignees
Labels
ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/imports