Import gazelle

This patch imports gazelle as a linter. It automatically generates
BUILD file entries for Go code and at the same time keeps BUILD files
formatted.

The `tools/lint:run-ci` target is set up to automatically add new Go
repositories as well.

I added a tool at `//tools/go:mirror_go_repos` that needs to be run
before anyone can merge code that uses third-party Go libraries.

Change-Id: I1fbf6761439d45893f5be88d294ccc3c567840ca
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
diff --git a/tools/lint/BUILD b/tools/lint/BUILD
index 30fc7c9..80b4aa1 100644
--- a/tools/lint/BUILD
+++ b/tools/lint/BUILD
@@ -1,3 +1,5 @@
+load("@ci_configure//:ci.bzl", "RUNNING_IN_CI")
+
 sh_binary(
     name = "gofmt",
     srcs = ["gofmt.sh"],
@@ -16,7 +18,16 @@
     ],
     data = [
         ":gofmt",
+        "//:gazelle-runner",
+        "//tools/go:tweak_gazelle_go_deps",
+        "@go_sdk//:bin/go",
     ],
+    env = {
+        # Prevent CI errors like:
+        #   failed to initialize build cache at
+        #   /var/lib/buildkite-agent/.cache/go-build: permission denied
+        "RUNNING_IN_CI": "1" if RUNNING_IN_CI else "0",
+    },
     deps = [
         "@bazel_tools//tools/bash/runfiles",
     ],