1. Setup Go Lang
-
Download Go Win V1.22.3 Amd64
-
Unzip to D:/Install/FreeDev/Go1223WinAmd64
go version
go version go1.22.3 windows/amd64
2. Environment Variable
Entry | Memo |
---|---|
GOROOT |
D:/Install/FreeDev/Go1223WinAmd64 |
GOPATH |
D:/Install/Dev/GoSpasce |
PATH |
%GOROOT%\bin |
GOBIN |
%GOROOT%\bin |
3. LiteIde
-
工具 ⇒ 编辑当前环境 ⇒ System:
GOROOT=D:/Install/FreeDev/Go1223WinAmd64
GOBIN=D:/Install/FreeDev/Go1223WinAmd64/bin
GOARCH=amd64
GOOS=windows
CGO_ENABLED=1
PATH=%GOBIN%;%GOROOT%\bin;%PATH%
-
不要设置GOCACHE和GOENV
4. Entry Case
-
新建 ⇒ Go1 Command Project ⇒ 点击BR来构建和运行代码
-
名称:com/elf/product/ProductPrice
-
位置:D:\Install\Dev\GoSpasce\src\com\elf\product\ProductPrice;
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
D:/Install/FreeDev/Go1223WinAmd64/bin/go.exe build
[D:/Install/Dev/GoSpasce/src/com/elf/product/ProductPrice]
成功: 进程退出代码 0.
D:/Install/Dev/GoSpasce/src/com/elf/product/ProductPrice/ProductPrice.exe
[D:/Install/Dev/GoSpasce/src/com/elf/product/ProductPrice]
Hello World!
成功: 进程退出代码 0.
5. go env
$ go env
set GO111MODULE=auto
set GOARCH=amd64
set GOBIN=D:\Install\FreeDev\Go1223WinAmd64\bin
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\Install\Dev\GoSpasce\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:/Install/Dev/GoSpasce
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Install\FreeDev\Go1223WinAmd64
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\Install\FreeDev\Go1223WinAmd64\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build455096475=/tmp/go-build -gno-record-gcc-switches