环境准备
169字小于1分钟
2025-02-03
go安装包下载
英文:https://golang.google.cn/dl/
windows安装
参考:https://blog.csdn.net/qq_44830881/article/details/123457805
Linux安装
cd /opt
wget https://studygolang.com/dl/golang/go1.21.3.linux-amd64.tar.gz
tar -xvf go1.21.3.linux-amd64.tar.gz
#配置环境变量
vim /etc/profile
在文件后追加以下内容
export GOPROXY=https://goproxy.cn
export GOROOT=/opt/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/opt/go/pkg
export PATH=$PATH:$GOPATH/bin
退出并保存,刷新环境变量
source /etc/profile
开发工具的选择
首选肯定是goland,当然vscode也是可以的
goland下载
https://www.jetbrains.com/go/download/other.html
vscode下载
https://code.visualstudio.com/
然后去下载go的插件就好了
编写第一个Go代码实例
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}