go打卡第一天-环境配置

114 阅读1分钟

安装go

1、下载go安装包

官网地址:​ ​golang.google.cn/dl/​​

中文地址:​ ​studygolang.com/dl​​

Go中文学习文档:​ ​topgoer.cn/docs/golang…

配置环境

go安装成功后默认目录是:/usr/local/go

1.进入配置文件

vim ~/.bash_profile

2.添加配置

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

3.保存,配置生效

source .bash_profile

4.验证一下

go version

创建一个go程序验证一下

vim test.go

package main
import "fmt"
func main(){
   fmt.Println("hello world!")
}

执行一下 go run test.go

最后就可以用VS Code 或者GoLand 撸代码啦!

截屏2022-05-10 17.12.24.png