intellij: use Bazel-built goimports
Test Plan: Tested the watcher, it fixed my code
X-Origin-Diff: phab/D663
GitOrigin-RevId: 0e06b3a4043e1671d8bb553312c8894d7c916933
diff --git a/BUILD b/BUILD
index af96778..123670e 100644
--- a/BUILD
+++ b/BUILD
@@ -78,6 +78,8 @@
toolchain_type = "@rules_python//python:toolchain_type",
)
+# Shortcuts for top-level binaries/tools
+
# Shortcut for kubectl when running through bazel run
# (don't depend on this, it might turn into an env-based PATH shortcut, use
# @io_k8s_kubernetes//cmd/kubectl instead)
@@ -103,3 +105,9 @@
name = "launch-multi2",
actual = "//core/cmd/launch-multi2",
)
+
+alias(
+ name = "goimports",
+ actual = "@org_golang_x_tools//cmd/goimports:goimports",
+ visibility = ["//visibility:public"],
+)
diff --git a/build/fietsje/main.go b/build/fietsje/main.go
index 1500623..5da9b49 100644
--- a/build/fietsje/main.go
+++ b/build/fietsje/main.go
@@ -128,6 +128,9 @@
"github.com/flynn/go-shlex",
)
+ // goimports
+ p.collectOverride("golang.org/x/tools", "v0.0.0-20201215171152-6307297f4651")
+
// First generate the repositories starlark rule into memory. This is because rendering will lock all unlocked
// dependencies, which might take a while. If a use were to interrupt it now, they would end up with an incomplete
// repositories.bzl and would have to restore from git.
diff --git a/intellij/localconfig/data/watcherTasks.xml b/intellij/localconfig/data/watcherTasks.xml
index 4d6e6a8..df92a5b 100644
--- a/intellij/localconfig/data/watcherTasks.xml
+++ b/intellij/localconfig/data/watcherTasks.xml
@@ -22,7 +22,7 @@
<envs />
</TaskOptions>
<TaskOptions isEnabled="true">
- <option name="arguments" value="-local git.monogon.dev -w $FilePath$" />
+ <option name="arguments" value="run //:goimports -- -local git.monogon.dev -w $FilePath$" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
@@ -34,7 +34,7 @@
<array />
</option>
<option name="outputFromStdout" value="false" />
- <option name="program" value="$USER_HOME$/.local/bin/goimports" />
+ <option name="program" value="$WorkspaceRoot$/scripts/bin/bazel" />
<option name="runOnExternalChanges" value="false" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="true" />
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index e934373..e9cfacf 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -1627,6 +1627,12 @@
sum = "h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=",
)
go_repository(
+ name = "org_golang_x_tools",
+ importpath = "golang.org/x/tools",
+ version = "v0.0.0-20201215171152-6307297f4651",
+ sum = "h1:bdfqbHwYVvhLEIkESR524rqSsmV06Og3Fgz60LE7vZc=",
+ )
+ go_repository(
name = "org_golang_x_xerrors",
importpath = "golang.org/x/xerrors",
version = "v0.0.0-20191204190536-9bdfabe68543",
diff --git a/third_party/go/shelf.pb.text b/third_party/go/shelf.pb.text
index e78522e..8e4c3dc 100644
--- a/third_party/go/shelf.pb.text
+++ b/third_party/go/shelf.pb.text
@@ -2526,6 +2526,13 @@
semver: "v0.0.0-20191024005414-555d28b269f0"
>
entry: <
+ import_path: "golang.org/x/tools"
+ version: "v0.0.0-20201215171152-6307297f4651"
+ bazel_name: "org_golang_x_tools"
+ sum: "h1:bdfqbHwYVvhLEIkESR524rqSsmV06Og3Fgz60LE7vZc="
+ semver: "v0.0.0-20201215171152-6307297f4651"
+>
+entry: <
import_path: "golang.org/x/xerrors"
version: "v0.0.0-20191204190536-9bdfabe68543"
bazel_name: "org_golang_x_xerrors"