1. 下载并解压go安装包到  /usr/local/目录

wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz
tar -C /usr/local/ -xzf go1.12.5.linux-amd64.tar.gz

2. 创建环境变量,并生效

(1) vim /etc/profile.d/go.sh
(2) export PATH=$PATH:/usr/local/go/bin
(3) source /etc/profile.d/go.sh

3. 创建Go的工作目录dev/go, 并输出GOPATH环境变量

(1) vim /etc/profile.d/gopath.sh
(2) export GOPATH=/root/dev/go
(3) source /etc/profile.d/gopath.sh

4. 验证GOPATH 环境变量是否生效

[root@image-build github.com]# echo $GOPATH
/root/dev/go

5. 下载delve,并编译

git clone https://github.com/go-delve/delve.git $GOPATH/src/github.com/go-delve/delve
cd $GOPATH/src/github.com/go-delve/delve
make install

6. 配置delve的启动位置

 export PATH=$PATH:$GOPATH/bin

Logo

更多推荐