Go module
1.16 でまた挙動が変わっている模様
module path は module name を兼ねる。module path はモジュールがどこにあるかを示すとともに、モジュール名でもある。
A Go package can be split into multiple files
つまり同じディレクトリ内のファイルはすべて同じ package と期待される
特定のブランチの HEAD を go.mod に入れる場合
-d は go.mod を変更するだけで download などをしない
code:terminal
go get -d repo_name@branch_name
1.13 以降はデフォルトでオン
それ以前は GO111MODULE 環境変数を設定する
vendor
vendor ないの module を触って debug するときは
code:terminal
$ go run -mod=vendor main.go
1.14 以降は vendor がデフォルトなので、go run command などは vendor ディレクトリがある場合はそのパッケージを使う
If the vendor directory is present in the main module’s root directory, it will be used automatically if the go version in the main module’s go.mod file is 1.14 or higher. To explicitly enable vendoring, invoke the go command with the flag -mod=vendor.
1.16 以上は module-aware mode が default で on になっている
By default, if the go version in go.mod is 1.14 or higher and a vendor directory is present, the go command acts as if -mod=vendor were used.
vendor ディレクトリがない時はどうなる?
Most go commands may run in Module-aware mode or GOPATH mode. In module-aware mode, the go command uses go.mod files to find versioned dependencies, and it typically loads packages out of the module cache, downloading modules if they are missing.
なので、module cache を使う、と読める
go get from private repository
基本方針
GOPRIVATE を設定して、git が対象のプライベートリポジトリにアクセスできるように設定する
PAT を使わない方法はないのか?
GOPRIVATE