0
1

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 3 years have passed since last update.

go testで"go: cannot find main module; see 'go help modules'"が出てきたとき

Posted at

Goのバージョンをアップデートした後にgo testを実行したら,

go: cannot find main module; see 'go help modules'

と出てきて,先に進まない

調べてみると,GO111MODULEという環境変数が問題らしい
この環境変数が'on'になっているのが問題だと書いてあるところが多いのだが,私の場合は何も入っていなかった

対処方法

GO111MODULEを'auto'と設定するとうまくいった

go1.13以降だと,go env コマンドに -w オプションを付けて環境変数を設定できる

go env -w GO111MODULE=auto

ok.

参考文献

Go 言語の環境変数管理
VSCodeでGo開発、”cannot find main module;”

0
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?