[go] Restrict go runtime to being fuchsia-only

This is step 3 of 3 of a restricting of the Golang Runtime to only
fuchsia binaries, as the last remaining host binaries are tests that
are also run on fuchsia.

This does the final visibility restriction change, so that the go
runtime is only available to fuchsia binaries.

Change-Id: If1052c05aeb1c9fed3f04a9efc6d60593b62b17d
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/go/+/1142622
Commit-Queue: Aaron Wood <aaronwood@google.com>
Reviewed-by: Ian McKellar <ianloic@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 69c95c0..c6187ac 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -49,7 +49,7 @@
   }
 
   compiled_action("makefuchsia") {
-    visibility = [ ":go_runtime" ]
+    visibility = [ ":create_go_runtime" ]
     deps = [
       ":makeroot",
       "//sdk/lib/fdio",
@@ -80,17 +80,22 @@
       rebase_path(_output, root_build_dir),
     ]
   }
-}
 
-group("go_runtime") {
-  if (is_host) {
+  group("create_go_runtime") {
     public_deps = [ ":makefuchsia(${toolchain_variant.base})" ]
-  } else {
-    public_deps = [ ":$target_name(${host_toolchain})" ]
+
+    # The host-toolchain target is restricted in visibility to just this redirection target.
+    visibility = [ ":go_runtime" ]
   }
 }
 
 if (is_fuchsia) {
+  # This is the go runtime itself.  It's only defined for the fuchsia toolchain(s)
+  group("go_runtime") {
+    # The target that creates it is only defined in the host toolchain.
+    public_deps = [ ":create_go_runtime(${host_toolchain})" ]
+  }
+
   go_test("go_exec_test") {
     gopackages = [ "os/exec" ]
   }