24
Linux下搭建简易go环境
source link: https://studygolang.com/articles/30781
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.配置apt源
vim /etc/apt/sources.list
然后复制以下内容,当然为了保险起见可以先备份原文件
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
2.安装golang
sudo apt-get install golang
3.设置gopath , 用于放置第三方lib库文件
1.临时修改:export GOPATH=/opt/go
2.直接修改 ~/.bashrc
echo export GOPATH=/opt/go >> ~/.bashrc
3.编写第一个go程序
package main import "fmt" func main() { fmt.Println("Hello world!") }
4.运行go build
go build main.go ./main
有疑问加站长微信联系
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK