0
2

More than 3 years have passed since last update.

Goのdepで既に指定済みのbranchと異なるbranchを参照させる方法

Last updated at Posted at 2020-07-29

概要

Goのdepで既にインストール済の依存パッケージに関して、既に指定されているブランチとは別のブランチを参照させるようにする方法についてです。
例えば、既にmasterブランチを参照する設定になっていたとして、一時的に開発中のfeature/sugoiブランチを参照させたい場合には以下のような手順で参照先のブランチを変えることができます。

Gopkg.tomlで指定済のbranch名を変更する

Gopkg.tomlの該当パッケージのbranch名指定(branch=xxxxx)を変更する。

変更前

仮にmasterブランチを参照している状態だとする。

[[constraint]]
  name = "github.com/hogehoge/fuga"
  branch = "master"

変更前

branchの指定を、参照させたいブランチ(ここではfeature/sugoi)に変更する。
なお参照させたいブランチは、githubからダウンロード可能な状態(githubにpush済)である必要がある。

[[constraint]]
  name = "github.com/hogehoge/fuga"
  branch = "feature/sugoi"

dep ensureを実行

Gopkg.tomlの記述内容を変更した状態でdep ensureを実行する。

dep ensure

これで、依存モジュールがGopkg.tomlで指定したブランチのものに更新される。

元に戻したいとき

Gopkg.tomlを元の内容に戻し、再度dep ensureを実行すればよい。

0
2
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
2