Golang的环境配置与helloworld运行
1. 环境配置
进入此https://studygolang.com/dl
下载对应平台的对应版本
一路next就可以安装好并自动配置好环境变量
通过go env
和 go version
命令语句查看是否安装好即可
前者返回如下即成功
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\61786\AppData\Local\go-build
set GOENV=C:\Users\61786\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\61786\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\61786\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=G:\
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=G:\pkg\tool\windows_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:\Users\61786\AppData\Local\Temp\go-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