Lecstor's Blog

Golang Cheatsheet

January 27, 2019

Learning Go, so started recording references to all the useful things I find so I can find them again when I need them..


$ brew update && brew install go

or download from Golang Downloads and install


$ go test - run tests

Generate Tests

gotests - Generate Go tests from your source code

$ gotests -w -all ./client.go > client_test.go


$ go test -cover - run tests and write coverage profile to cover.out

$ go tool cover -html=cover.out - view covered/not covered code in browser

go tool cover -help - for more

Testing Resources


Cache Clean

Cleaning the go caches once fixed some “unknown import path”/“cannot find module providing package” errors (Package Clean)

$ go clean -cache -modcache -i -r


Jason Galea

Written by Jason Galea from Cairns, Australia.

Full Stack developer specialising in React and NodeJS.

LinkedIn | Github | StackOverflow | Twitter