-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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: 'imports' does not seem to prefer current major version import path. #60824
Comments
Thank you for the issue. Creating a new category of bug for these goimports problems. There is a larger project to rewrite the goimports algorithm. |
Duplicate of #58382 |
Thank you. To use github as a lab notebook: I reproduced it with 'go mod init foo.com' and in a new foo.go file put 'package foo; import "fyne.io/fyne/v2/app"; var _ = app.New()'. gopls reports that it cannot find the import, so 'go mod tidy' loads lots of modules into the module cache and the error goes away. Add 'var _ dialog.NewError to the foo.go file, and imports does indeed insert "fyne.io/fyne/dialog". This is incorrect, as it should have preferred the NewError from v2. |
@pjweinb You can denote inline codeblocks with backticks instead of quotes. For example, `example` will produce |
Change https://go.dev/cl/582557 mentions this issue: |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.11.0
golang.org/x/tools/gopls@v0.11.0 h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY=
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp@v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
golang.org/x/exp/typeparams@v0.0.0-20221031165847-c99f073a8326 h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4=
golang.org/x/mod@v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/sync@v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys@v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/text@v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/tools@v0.3.1-0.20221213193459-ca17b2c27ca8 h1:7/HkGkN/2ktghBCSRRgp31wAww4syfsW52tj7yirjWk=
golang.org/x/vuln@v0.0.0-20221109205719-3af8368ee4fe h1:qptQiQwEpETwDiz85LKtChqif9xhVkAm8Nhxs0xnTww=
honnef.co/go/tools@v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.3
Run
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Check your installed extensions to get the version of the VS Code Go extension
Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) >
Go: Locate Configured Go Tools
command.GOBIN: undefined
toolsGopath:
gopath: /Users/andy/.go
GOROOT: /opt/homebrew/Cellar/go/1.20.3/libexec
PATH: /opt/homebrew/opt/ruby/bin:/opt/homebrew/opt/openjdk/bin:/Users/andy/.go/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
go: /opt/homebrew/bin/go: go version go1.20.3 darwin/arm64
gotests: not installed
gomodifytags: not installed
impl: not installed
goplay: not installed
dlv: /Users/andy/.go/bin/dlv (version: v1.20.2 built with go: go1.20.3)
staticcheck: not installed
gopls: /Users/andy/.go/bin/gopls (version: v0.11.0 built with go: go1.20.3)
go env
Workspace Folder (2-packinglist): /Users/andy/Code/FyneLabs/Udemy-FyneBeginner/2-packinglist
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andy/Library/Caches/go-build"
GOENV="/Users/andy/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andy/.go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andy/.go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.3/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/Users/andy/Code/FyneLabs/Udemy-FyneBeginner/2-packinglist/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/pc/1mt578kn6615qkxsygpwrw7m0000gn/T/go-build4076799024=/tmp/go-build -gno-record-gcc-switches -fno-common"
Share the Go related settings you have added/edited
Just the generic AutoSave = onFocusChange
Describe the bug
The Go import suggestion (auto-adding) does not seem to realise that a project is using v2 import path once server has a breaking change beyond v0/1
Steps to reproduce the behavior:
a := app.New()
into amain()
functiondialog.NewError
and save to trigger import generationv2
. On some versions it inserts "fyne.io/fyne/dialog" which is not compatible (old v1 api) - though after a recent update it is making up an import path of "fyne.io/fyne/v2/rc1/dialog" which has never been used.Screenshots or recordings
The text was updated successfully, but these errors were encountered: