golangのパッケージ管理ツールglideが非推奨になっていることに気づく・・
概要
golang1.11がリリースされたので、言語のバージョンアップと一緒に利用しているパッケージのバージョンも確認していたところ、glideのgithub上に以下の記載がありました。
Golang Dep
The Go community now has the dep project to manage dependencies. Please consider trying to migrate from Glide to dep. If there is an issue preventing you from migrating please file an issue with dep so the problem can be corrected. Glide will continue to be supported for some time but is considered to be in a state of support rather than active feature development.ent.
github GitHub - Masterminds/glide: Package Management for Golang
いずれdisconになるので、depへの切替を検討して下さいとのこと。すぐにやらないとこういったことは、後回しにされがちなので、対応しました。
環境
depの導入
depコマンドをhomebrewを使ってインストールします。
% brew install dep ==> Downloading https://homebrew.bintray.com/bottles/dep-0.5.0.high_sierra.bottle.tar.gz ==> Pouring dep-0.5.0.high_sierra.bottle.tar.gz 🍺 /usr/local/Cellar/dep/0.5.0: 7 files, 9.1MB
これで、depがインストールされたので、ヘルプを表示してから、バージョン確認をしてみます。
% dep --help [master] Dep is a tool for managing dependencies for Go projects Usage: "dep [command]" Commands: init Set up a new Go project, or migrate an existing one status Report the status of the project's dependencies ensure Ensure a dependency is safely vendored in the project version Show the dep version information check Check if imports, Gopkg.toml, and Gopkg.lock are in sync Examples: dep init set up a new project dep ensure install the project's dependencies dep ensure -update update the locked versions of all dependencies dep ensure -add github.com/pkg/errors add a dependency to the project Use "dep help [command]" for more information about a command. % dep version [master] dep: version : v0.5.0 build date : 2018-07-26 git hash : 224a564 go version : go1.10.3 go compiler : gc platform : darwin/amd64 features : ImportDuringSolve=false
glideからのコンバート
glide.ymlが存在するディレクトリに移動して、dep init
を実行すると、dep側でglideの内容を読み取って、dep用のパッケージ管理ファイルを生成してくれます。これは助かります。
% dep init -v [master] Getting direct dependencies... Checked 12802 directories for packages. Found 24 direct dependencies. Importing configuration from glide. These are only initial constraints, and are further refined during the solve process. Detected glide configuration files... Loading /Users/k-goto/go/src/github.com/ekps/ekps_go/glide.yaml Loading /Users/k-goto/go/src/github.com/ekps/ekps_go/glide.lock Converting from glide.yaml and glide.lock... 〜 Importing configuration from godep. These are only initial constraints, and are further refined during the solve process. Importing configuration from govendor. These are only initial constraints, and are further refined during the solve process.
コマンドの実行正常が終わると、depから以下のファイルが生成されます。
- Gopkg.toml
- Gopkg.lock
- vendor/*
ここまで出来ていれば、正常にビルドが通るようになります。 問題なくconvert出来れば、楽なのですが、以下のようなエラーが発生しました。
init failed: unable to solve the dependency graph: Solving failure: No versions of gopkg.in/fsnotify.v1 met constraints: 7be54206639f256967dd82fa767397ba5f8f48f5: unable to update checked out version: fatal: reference is not a tree: 7be54206639f256967dd82fa767397ba5f8f48f5 : command failed: [git checkout 7be54206639f256967dd82fa767397ba5f8f48f5]: exit status 128 7be54206639f256967dd82fa767397ba5f8f48f5: unable to update checked out version: fatal: reference is not a tree: 7be54206639f256967dd82fa767397ba5f8f48f5 : command failed: [git checkout 7be54206639f256967dd82fa767397ba5f8f48f5]: exit status 128
これは、githubのurlが正しく無いので、checkoutに失敗しているために、発生しています。上の例だと、fsnotifyというパッケージのURLが変更されているようなので、確認してみると以下のように変更されていました。
fsnotifyは、他のパッケージの依存で利用されているようなので、原因となるパッケージを調べて、削除します。
% glide tree | grep fsnotify 〜 tailというpackageが依存で利用していることがわかる % glide rm github.com/hpcloud/tail
パッケージの確認
depにすると、利用パッケージの状況が以下のようにとても見やすくなります。
% dep status PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED bitbucket.org/tebeka/strftime branch default branch default 2194253 2194253 1 github.com/Sirupsen/logrus ^0.11.5 v0.11.5 ba1b36c v0.11.5 1 github.com/alouca/gologger branch master branch master 7d4b729 7d4b729 1 github.com/alouca/gosnmp branch master branch master 04d8394 04d8394 1 github.com/bradfitz/slice branch master branch master 2b758aa 2b758aa 1 github.com/elazarl/go-bindata-assetfs branch master branch master 38087fe 38087fe 1 github.com/gin-contrib/sse branch master branch master 22d885f 22d885f 1
- CONSTRAINT: 現在利用しているバージョン
- VERSION: 配信されている最新バージョン
- PKGS USED: 他のパッケージで利用されている回数(依存含む)
これで、無事にdepに切り替えることが出来ました。
しかし、golangは変更がドラスティックに行われるので、付いていくのが大変だ・・・。活発ってことだからいいことではあると思いますが。これからもキャッチアップに勤しみます。