LoginSignup
1
1

More than 5 years have passed since last update.

EC2にGoのパッケージ依存関係ツールdepをインストールする

Last updated at Posted at 2017-03-08

EC2にyumでepelリポジトリで追加したgoでdepをインストールしようとすると今現在エラーが出てできない。

$ sudo yum install -y golang
$ go get -u github.com/golang/dep/...
# github.com/golang/dep
..\github.com\golang\dep\lock.go:130: enc.SetIndent undefined (type *json.Encoder has no field or method SetIndent)
..\github.com\golang\dep\lock.go:131: enc.SetEscapeHTML undefined (type *json.Encoder has no field or method SetEscapeHTML)
..\github.com\golang\dep\manifest.go:129: enc.SetIndent undefined (type *json.Encoder has no field or method SetIndent)
..\github.com\golang\dep\manifest.go:130: enc.SetEscapeHTML undefined (type *json.Encoder has no field or method SetEscapeHTML)

このときインストールされているgoが1.6.3となっている。

$ go version
go version go1.6.3 linux/amd64

depのissueによると1.7以上でないといけないそうです。
https://github.com/golang/dep/issues/230

バージョン1.6.3のGoを削除する。

$ sudo yum remove golang

バージョン1.7のGoをインストールする。

$ cd /tmp
$ wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz
$ tar -xvf go1.7.linux-amd64.tar.gz
$ mv go/ /usr/local/go/
$ echo "export GOPATH=${HOME}/.golang" >> ~/.bashrc
$ echo "export GOROOT=/usr/local/go" >> ~/.bashrc
$ echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH" >> ~/.bashrc
$ . ~/.bashrc

goが1.7以上になったことを確認。

$ go version
go version go1.7 linux/amd64

以上でインストールして使えるようになる。

$ mkdir -p $GOPATH/src/production
$ cd $GOPATH/src/production
$ git clone https://github.com/xxxxxxxxxx/xxxxxxxxxxxx.git .

$ go get -u github.com/golang/dep/...
$ dep init
$ dep ensure

参考

http://mattn.kaoriya.net/software/lang/go/20170125023240.htm
https://tecadmin.net/install-go-on-centos/

1
1
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
1
1