Define //:gofmt Bazel target and use it everywhere.

Bug: skia:13588
Change-Id: Ie15fd39d6693ffdf2a5ddba33db1ade2a5745975
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/562819
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Auto-Submit: Leandro Lovisolo <lovisolo@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
diff --git a/BUILD.bazel b/BUILD.bazel
index 4a5e8a7..2389976 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -188,6 +188,16 @@
           "cd .. && rm -rf tmp_task_drivers",
 )
 
+#########
+# gofmt #
+#########
+
+alias(
+    name = "gofmt",
+    actual = "@go_sdk//:bin/gofmt",
+    visibility = ["//visibility:public"],
+)
+
 ###########
 # Mockery #
 ###########
diff --git a/Makefile b/Makefile
index afe6b81..093f48f 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,10 @@
 buildifier:
 	$(BAZEL) run //:buildifier
 
+.PHONY: gofmt
+gofmt:
+	$(BAZEL) run //:gofmt -- -s -w .
+
 .PHONY: bazel-build
 bazel-build:
 	$(BAZEL) build //...
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 43f60c0..cc29d64 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -252,7 +252,7 @@
   if not input_api.AffectedSourceFiles(_MakeFileFilter(input_api, ['go'])):
     return []
   return _RunCommandAndCheckGitDiff(
-      input_api, output_api, ['gofmt', '-s', '-w', '.'])
+      input_api, output_api, ['make', 'gofmt'])
 
 def CheckChange(input_api, output_api):
   """Presubmit checks for the change on upload or commit.
@@ -271,7 +271,7 @@
   * No JS debugging artifacts.
   * No Buildifier diffs.
   * No Gazelle diffs.
-  * No gmfmt diffs.
+  * No gofmt diffs.
   """
   results = []
 
diff --git a/infra/bots/task_drivers/bazel_build_all/bazel_build_all.go b/infra/bots/task_drivers/bazel_build_all/bazel_build_all.go
index 491893f..f6060f9 100644
--- a/infra/bots/task_drivers/bazel_build_all/bazel_build_all.go
+++ b/infra/bots/task_drivers/bazel_build_all/bazel_build_all.go
@@ -71,12 +71,6 @@
 	}
 	failIfNonEmptyGitDiff()
 
-	// Run "go fmt" and fail it there are any diffs.
-	if _, err := golang.Go(ctx, gitDir.Dir(), "fmt", "./..."); err != nil {
-		td.Fatal(ctx, err)
-	}
-	failIfNonEmptyGitDiff()
-
 	// Run "errcheck" and fail if there are any findings.
 	//
 	// For some reason, exec.RunCwd cannot find the errcheck binary without an absolute path, which
@@ -109,6 +103,12 @@
 		td.Fatal(ctx, err)
 	}
 
+	// Run "go fmt" and fail it there are any diffs.
+	if _, err := bzl.Do(ctx, "run", "//:gofmt", "--", "-s", "-w", "."); err != nil {
+		td.Fatal(ctx, err)
+	}
+	failIfNonEmptyGitDiff()
+
 	// Buildifier formats all BUILD.bazel and .bzl files. We enforce formatting by making the tryjob
 	// fail if this step produces any diffs.
 	if _, err := bzl.Do(ctx, "run", "//:buildifier"); err != nil {