1. 环境配置
进入此https://studygolang.com/dl
下载对应平台的对应版本
一路next就可以安装好并自动配置好环境变量
通过go env
和 go version
命令语句查看是否安装好即可
前者返回如下即成功
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:Users61786AppDataLocalgo-build
set GOENV=C:Users61786AppDataRoaminggoenv
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:Users61786gopkgmod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:Users61786go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=G:
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=G:pkg oolwindows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:Users61786AppDataLocalTempgo-build094581290=/tmp/go-build -gno-record-gcc-switches
后者返回对应版本go version go1.15.3 windows/amd64
2. 第一个golang程序 hello world
// Hello.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World! Welcome to Go Lang!")
}
这里用的是vscode编译,可以用别的IDE比如LiteIDE和Goland