Go tools
Go cross-platform compile
goxc
A build tool for Go, with a focus on cross-compiling, packaging and deployment
goxc -d=build -pv=0.1.0
See https://github.com/laher/goxc
Word count
cnwordcount
Count Chinese characters in a file.
$ cnwordcount -f file.md
file.md 12
See https://github.com/rootsongjc/cnwordcount
Type transfer
JSON to go
JSON
{"a":"11","b":"23"}
Go
type AutoGenerated struct {
A string `json:"a"`
B string `json:"b"`
}
See https://mholt.github.io/json-to-go/
CURL to go
CURL
curl https://api.example.com/surprise \
-u banana:coconuts \
-d "sample data"
Go
// Generated by curl-to-Go: https://mholt.github.io/curl-to-go
body := strings.NewReader(`sample data`)
req, err := http.NewRequest("POST", "https://api.example.com/surprise", body)
if err != nil {
// handle err
}
req.SetBasicAuth("banana", "coconuts")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// handle err
}
defer resp.Body.Close()