Add golangci-lint to our CI
This MR adds golangci-lint
to our CI pipeline and fixes current offences.
This iteration includes these linters:
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
deadcode: Finds unused code
ineffassign: Detects when assignments to existing variables are not used
structcheck: Finds unused struct fields
typecheck: Like the front-end of a Go compiler, parses and type-checks Go code
varcheck: Finds unused global variables and constants
Enabling all of the default linters wasn't working correctly with the default docker image, so I've decided to ship MVP first.
Current offences
$ golangci-lint run
integration_test.go:45:17: Error return value of `json.Unmarshal` is not checked (errcheck)
json.Unmarshal([]byte(gci), &gitalyConnInfo)
^
integration_test.go:129:21: Error return value of `client.DeleteIndex` is not checked (errcheck)
client.DeleteIndex()
^
elastic/client_test.go:213:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(`{}`))
^
elastic/client_test.go:350:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(`{}`))
^
git/repository_test.go:42:17: Error return value of `json.Unmarshal` is not checked (errcheck)
json.Unmarshal([]byte(gci), &gitalyConnInfo)
^
indexer/indexer_test.go:215:7: Error return value is not checked (errcheck)
index(idx)
^
elastic/client.go:22:2: `envCorrelationIDKey` is unused (deadcode)
envCorrelationIDKey = "CORRELATION_ID"
^
Edited by Dmitry Gruzd