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: 'imports' does not seem to prefer current major version import path. #60824

Open
andydotxyz opened this issue Jun 12, 2023 · 1 comment
Labels
gopls/imports gopls Issues related to the Go language server, gopls.
Milestone

Comments

@andydotxyz
Copy link
Contributor

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • 1.20.3
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info

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 or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.78.2
  • Check your installed extensions to get the version of the VS Code Go extension

    • 0.38.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • Checking configured tools....
      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:

  1. Create a new project with go module etc
  2. Import "fyne.io/fyne/v2/app"
  3. Add a := app.New() into a main() function
  4. Save and all should be well
  5. Now type something like dialog.NewError and save to trigger import generation
  6. Notice that the import is not v2. 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

Screenshot 2023-06-12 at 10 49 26

@hyangah hyangah added the gopls Issues related to the Go language server, gopls. label Jun 12, 2023
@findleyr findleyr changed the title VSCode Go does not seem to prefer current major version import path. x/tools/gopls: does not seem to prefer current major version import path. Jun 15, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Jun 15, 2023
@findleyr findleyr added this to the gopls/v0.13.0 milestone Jun 15, 2023
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 15, 2023
@findleyr findleyr added gopls/imports and removed Tools This label describes issues relating to any tools in the x/tools repository. labels Jun 15, 2023
@findleyr
Copy link
Contributor

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.

@adonovan adonovan changed the title x/tools/gopls: does not seem to prefer current major version import path. x/tools/gopls: 'imports' does not seem to prefer current major version import path. Jul 4, 2023
@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.15.0 Oct 9, 2023
@findleyr findleyr modified the milestones: gopls/v0.15.0, gopls/v0.16.0 Dec 12, 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.
Projects
None yet
Development

No branches or pull requests

4 participants