go mod 的使用 1 2 3 4 5 6 7 8 go mod init "xxx" go mod edit -replace=golang.org/x/sys@v0.0.0=github.com/golang/sys@v0.0.0 go mod tidy go mod vendor
设置国内源 1 2 export GOPROXY=https://goproxy.ioexport GOPROXY=https://mirrors.aliyun.com/goproxy/
go 可能需要用到的环境变量 1 2 3 4 5 6 export GOROOT=/usr/local /goexport GOARCH=amd64export GOPATH=/usr/local /gopathexport GOBIN=$GOPATH /binexport PATH=$PATH :$GOPATH /binexport GOBIN=/home/linuxbrew/.linuxbrew/bin/
开启或关闭go mod 1 2 3 4 export GO111MODULE=auto
go类型转换
转载:https://www.jb51.net/article/119164.htm
int转string 1 2 s := strconv.Itoa(i) s := strconv.FormatInt(int64 (i), 10 )
int64转string 1 2 i := int64 (123 ) s := strconv.FormatInt(i, 10 )
string转int 1 i, err := strconv.Atoi(s))
string转int64 1 i, err := strconv.ParseInt(s, 10 , 64 )
go 字符串操作
转载:https://blog.csdn.net/li_101357/article/details/80241224 1 2 3 4 5 6 # 子串substr在s中,返回true func Contains (s, substr string ) bool # chars 中任何一个Unicode 代码点在s 中,返回true func ContainsAny (s, chars string ) bool # Unicode 代码点r 在s 中,返回true func ContainsRune (s string , r rune ) bool
电子书 《Effective Go》中英双语版