go build -gcflags=-warnunused
go test -gcflags=-warnunused
which causes the compiler to only warn about unused things instead of stopping the build:
$ go test -gcflags=-warnunused
# github.com/kstenerud/go-describe
./describe_unsafe.go:8:2: Warning: imported and not used: "fmt"
./describe.go:329:2: Warning: isInUnsignedArray declared but not used
...
PASS
ok github.com/kstenerud/go-describe 0.002s
I use this when debugging or for exploratory coding.
The warning flag patch allows you to do:
which causes the compiler to only warn about unused things instead of stopping the build: I use this when debugging or for exploratory coding.