在EC2上安装Go语言包依赖工具dep

目前在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的问题报告,据说必须使用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

请提供更多的详细信息。

以下是两个安装Go语言的教程链接:
1. http://mattn.kaoriya.net/software/lang/go/20170125023240.htm
2. https://tecadmin.net/install-go-on-centos/

广告
将在 10 秒后关闭
bannerAds