LoginSignup
0
0

JetBrain Goland で、 export GOPROXY=direct を有効にする方法

Posted at
go env -w GOPROXY=direct
go mod tidy

をTerminalで実行すれば、Moduleは直接取れるので、基本的にはそれでOK。

go mod tidyでは、$GOPATH/pkg/mod にパッケージが保存されるようになっている。

ただし、Goland側には、Vendoringという仕組みがある。
これは、プロジェクト内の vendor ディレクトリに格納されている依存関係パッケージのみを使用してアプリケーションを構築するというものだ。侵食耐性のある構成にするためだろう。

まず、
Settings > Go > Go Modules
に行く。

そこで、以下のように、
Environmentに、GOPROXY=directを設定しておく。

image.png

これで、Apply→OKとすると、re-download が始まった。

ちなみに、写真にあるように、

  • Enable vendoring support automatically

としていると、Vendoringが自動で有効になる。

余談

こちら側で、手動でVendoringしておきたい場合は、

go mod vendor

で、./vendor に $GOPATH/pkg/modの内容のコピーをとり、こちらを参照するようにできる。

Golandだけでなく、Go自体のランタイムもこちらのモジュールを参照して、buildおよびtestを実行するようになる。

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