Google:Golang,Learning(1)
安装Go语言:
1.源码
2.标准包
3.第三方工具
Microsoft Windows下的Go:
1 2 3 4 5 6 |
Windows PowerShell 版权所有 (C) 2009 Microsoft Corporation。保留所有权利。 PS C:\Users\adamhuan> go version go version go1.4rc1 windows/386 PS C:\Users\adamhuan> |
Go的环境变量:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
PS C:\Users\adamhuan> go env set GOARCH=386 set GOBIN= set GOCHAR=8 set GOEXE=.exe set GOHOSTARCH=386 set GOHOSTOS=windows set GOOS=windows set GOPATH=D:\go_code set GORACE= set GOROOT=D:\GO set GOTOOLDIR=D:\GO\pkg\tool\windows_386 set CC=gcc set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0 set CXX=g++ set CGO_ENABLED=1 PS C:\Users\adamhuan> |
Go的“help”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
PS D:\go_code> go help Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: build compile packages and dependencies clean remove object files env print Go environment information fix run go tool fix on packages fmt run gofmt on package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages run compile and run Go program test test packages tool run specified go tool version print Go version vet run go tool vet on packages Use "go help [command]" for more information about a command. Additional help topics: c calling between Go and C filetype file types gopath GOPATH environment variable importpath import path syntax packages description of package lists testflag description of testing flags testfunc description of testing functions Use "go help [topic]" for more information about that topic. PS D:\go_code> |
go get,获取远程包,需要原装:git、hg
go run,运行程序
go build,测试编译,是否有编译错误
go fmt,格式化源码,部分IDE在保存时会自动的调用
go install,编译包文件并编译整个程序
go test,运行测试文件
go doc,查看文档,CMM手册
Eg:godoc
1 2 3 4 5 6 7 8 9 |
PS D:\go_code> godoc fmt Println func Println(a ...interface{}) (n int, err error) Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. PS D:\go_code> |
——————————————
To be continue。