From 4346798760bcf843810de0f2cce4548cd16c9d03 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Mon, 5 Oct 2020 10:01:14 +0000 Subject: [PATCH] Update 'go-cheatsheet.md' --- go-cheatsheet.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/go-cheatsheet.md b/go-cheatsheet.md index 9173ab8..03fb46b 100644 --- a/go-cheatsheet.md +++ b/go-cheatsheet.md @@ -1,5 +1,26 @@ # go (golang) cheatsheet +## tools and environment + +goimports manages your import lines and should be used instead of fmt, golangci-lint will tell you when you're doing silly things, and gotest will do the same thing as `go test` but with color output in terminal. + +``` +go get golang.org/x/tools/cmd/goimports +go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0 +go get -u github.com/rakyll/gotest +``` + +## code style + +* obviously, always gofmt +* run golangci-lint + +## types and interfaces + +Accept and provide `String() string` method and the associated `fmt.Stringer` interface. + +Accept and provide `GoString() string` method so `%#v` (see below) works right. + ## testing ### use testify