Static analyzers for Go to enforce code consistency and discourage bad practices.
Breaking code example:
Resulting compilation error:
Forces the use of any
(introduced in Go 1.8) instead of interface{}
.
In your WORKSPACE
file:
http_archive(
name = "com_github_dorfire_go_analyzers",
sha256 = "2c07d07f67d7c402073548e8b1b36ffb23efa410d6958bacc4c12b02fcb1eac9",
strip_prefix = "go-analyzers-master",
urls = ["https://github.com/dorfire/go-analyzers/archive/refs/heads/master.tar.gz"],
)
In your NoGo target file (e.g. build/BUILD.bazel
):
load("@io_bazel_rules_go//go:def.bzl", "nogo")
nogo(
name = "nogo",
# ...
deps = [
"@com_github_dorfire_go_analyzers//src/onlyany",
"@com_github_dorfire_go_analyzers//src/visibilityorder",
# ...
],
)