在linux云服务器下配置GoLang环境
source link: https://studygolang.com/articles/16666?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1、下载go环境: Golang
当然你如果可以翻墙还可以去这个网址下载 : https://golang.org/dl/
下载对应版本的包
2、上传下载的文件
scp /Users/zt/Desktop/go1.11.2.linux-amd64.tar.gz [email protected]:/home/hz/桌面
3、给用户添加权限
(1)在root用户下运行vim /etc/sudoers
添加:对应的用户名添加权限,我的是hz
4、在服务器上解压缩
成功后去用户/usr/local查看有没有对应的go文件夹
5、配置go
终端下输入cd 进如当前用户主目录
vim .bashrc
在.bashrc添加对应指令
export GOROOT=/usr/local/go
export GOPATH=$HOME/GoLang
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
你如果按照上面步骤只需要改下第二条就可以,保存退出
运行:source .bashrc
查看go版本信息:go version
6、现在就去刚刚配置的GOPATH文件夹里写go就可以了
vim main.go
package main
func main() {
println("Hello world")
}
go run main.go
至此第一个go程序编写完成。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK