第一步 安装go
镜像下载地址:Golang Downloads Mirrors - The Go Programming Languagehttps://gomirrors.org/
Go语言中文网:Go下载 - Go语言中文网 - Golang中文社区https://studygolang.com/dl
下载地址:Downloads - The Go Programming Languagehttps://golang.google.cn/dl/
选择对应的操作系统版本,并下载,下载完成后一路next,配置环境变量
GOROOT:就是go的安装目录
GOPATH:workspace,类似工作空间,里面创建有src、bin、pkg三个目录.可以自己指定.
编辑path
安装Vscode,最后一个界面直接全打√号启动.
配置中文环境,安装go
先来个hello,world吧
package main
import (
"fmt"
)
func main() {
fmt.Println("hello,world")
}
弹出提示就直接install all.
运行,报错了
[Running] go run "d:\GoPath\src\test01\hello.go"
test01\hello.go:1:1: expected 'package', found 'EOF'
没保存导致的, Ctrl+s,再运行即可.