HCM

Happy Coding Monkey

Go Cheat Sheet

2021-06-01


Test

run go test without cache

# clean test case.
$ go clean -testcache

# with go flags
$ GOFLAGS="-count=1" go test -timeout 30s -tags test -run ^XXXX$ github.com/xxx/xx

generate go test binary

$ go test github.com/xxx/xx -run "^(TestAll)$" -c

Build

build binary for Raspberry Pi

# For Raspberry Pi 4 with 64bit Linux
$ CGO=0 GOOS=linux GOARCH=arm64 go get -u github.com/shadowsocks/go-shadowsocks2

# For Raspberry Pi 4 with 32bit Linux
$ CGO=0 GOOS=linux GOARCH=arm GOARM=7 go get -u github.com/shadowsocks/go-shadowsocks2

# For Raspberry Pi 1 with 32bit Linux
$ CGO=0 GOOS=linux GOARCH=arm GOARM=5 go -u github.com/shadowsocks/go-shadowsocks2

for x86, 64 bit linux

GOARCH=amd64 GOOS=linux go -u github.com/shadowsocks/go-shadowsocks2