0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

goplsやgoimportsでimport補完がバージョンを認識しないのを直す

Last updated at Posted at 2022-08-07

問題

go.mod
module github.com/k0kubun/test

go 1.19

require (
	github.com/k0kubun/pp/v3 v3.1.0
)

main.go
package main

func main() {
	pp.Println(1)
}

が置いてあるリポジトリで goimports main.go すると、import "github.com/k0kubun/pp/v3" が補完されてほしいのに import "github.com/k0kubun/pp" が補完されてしまうことがある。

対処法

"${GOPATH}/pkg/mod/github.com/k0kubun/pp@v3.0.1+incompatible" など、go.mod非互換のバージョンが残っていると再現する。なので "${GOPATH}/pkg/mod/github.com/k0kubun""${GOPATH}/pkg/mod/cache/download/github.com/k0kubun" を丸ごと削除したあと以下をやり直したりすると良い。

go get -t ./...

goplsはその後再起動しないといけないので、VSCode等はリロードする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?