依存関係管理ツールdep(golang)

久しぶりにgo言語関連アプリ、Big Sky :: Golang と Vue.js で簡単なアプリケーションを作ってみた。を使ってみようと思ったらパッケージがないって怒られました。

個別にインストールするのは面倒です…

$ go get -u xxx

nodeやrubyのパッケージ管理ツールがないのかと思っていたら、depというパッケージ管理ツールがありました。

これで簡単に試してみることができます。

$ get clone https://github.com/mattn/go-vue-example
$ cd go-vue-example
$ dep init
  Using ^3.3.4 as constraint for direct dep github.com/labstack/echo
  Locking in 3.3.4 (a5d81b8) for direct dep github.com/labstack/echo
  Locking in master (e746df9) for transitive dep github.com/valyala/bytebufferpool
  Locking in v3.2.0 (06ea103) for transitive dep github.com/dgrijalva/jwt-go
  Locking in 0.2.4 (6fe1405) for transitive dep github.com/labstack/gommon
  Locking in v0.0.9 (167de6b) for transitive dep github.com/mattn/go-colorable
  Using v1 as constraint for direct dep gopkg.in/check.v1
  Locking in v1 (20d25e2) for direct dep gopkg.in/check.v1
  Locking in master (12892e8) for transitive dep golang.org/x/crypto
  Using master as constraint for direct dep github.com/globalsign/mgo
  Locking in master (baa28fc) for direct dep github.com/globalsign/mgo
  Locking in v0.0.3 (0360b2a) for transitive dep github.com/mattn/go-isatty
  Using ^1.0.5 as constraint for direct dep github.com/sirupsen/logrus
  Locking in v1.0.5 (c155da1) for direct dep github.com/sirupsen/logrus
  Locking in master (378d26f) for transitive dep golang.org/x/sys
  Locking in master (dcecefd) for transitive dep github.com/valyala/fasttemplate

$ cat Gopkg.toml
#   name = "github.com/x/y"
#   version = "2.4.0"
#
# [prune]
#   non-go = false
#   go-tests = true
#   unused-packages = true


[[constraint]]
  branch = "master"
  name = "github.com/globalsign/mgo"

[[constraint]]
  name = "github.com/labstack/echo"
  version = "3.3.4"

$ cat Gopkg.lock
  # This file is autogenerated, do not edit; changes may be undone by the next     'dep ensure'.

   [[projects]]
    name = "github.com/dgrijalva/jwt-go"
    packages = ["."]
    revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e"
    version = "v3.2.0"

$ dep ensure
$ go build