Move generics out of util

In order to roll https://skia-review.googlesource.com/c/buildbot/+/565501
into CIPD, I need to make goldctl compatible with Go 1.17.
This was the only transitive dep of goldctl that uses
generics, so I hope it is enough to land it.

Change-Id: I8c1250e0dd0a2983a8fd7ed76ca7e58184d3296e
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/565677
Reviewed-by: Erik Rose <erikrose@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/go/util/util.go b/go/util/util.go
index 65fa158..b60a25d 100644
--- a/go/util/util.go
+++ b/go/util/util.go
@@ -893,11 +893,3 @@
 	// the default is false.
 	return false
 }
-
-// Get looks up an item in a map, returning a fallback value if absent.
-func Get[K comparable, V interface{}](theMap map[K]V, k K, fallback V) V {
-	if item, exists := theMap[k]; exists {
-		return item
-	}
-	return fallback
-}
diff --git a/go/util/util_test.go b/go/util/util_test.go
index 994b455..cc56fce 100644
--- a/go/util/util_test.go
+++ b/go/util/util_test.go
@@ -801,13 +801,3 @@
 	testCopy(0600, []byte("private stuff here"))
 	testCopy(0777, []byte("this is for everyone!"))
 }
-
-func TestGet(t *testing.T) {
-	unittest.SmallTest(t)
-	strings := map[string]int{
-		"one": 1,
-		"two": 2,
-	}
-	assert.Equal(t, 1, Get(strings, "one", 99))           // key present
-	assert.Equal(t, 99, Get(strings, "four billion", 99)) // key absent
-}
diff --git a/go/util_generics/BUILD.bazel b/go/util_generics/BUILD.bazel
new file mode 100644
index 0000000..b4e6942
--- /dev/null
+++ b/go/util_generics/BUILD.bazel
@@ -0,0 +1,19 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("//bazel/go:go_test.bzl", "go_test")
+
+go_library(
+    name = "util_generics",
+    srcs = ["util_generics.go"],
+    importpath = "go.skia.org/infra/go/util_generics",
+    visibility = ["//visibility:public"],
+)
+
+go_test(
+    name = "util_generics_test",
+    srcs = ["util_generics_test.go"],
+    embed = [":util_generics"],
+    deps = [
+        "//go/testutils/unittest",
+        "@com_github_stretchr_testify//assert",
+    ],
+)
diff --git a/go/util_generics/util_generics.go b/go/util_generics/util_generics.go
new file mode 100644
index 0000000..71b961d
--- /dev/null
+++ b/go/util_generics/util_generics.go
@@ -0,0 +1,12 @@
+// Package util_generics houses utility function which make us of generics. Chrome Infra
+// is locked to Go 1.17 to support Mac 10.11, so we cannot ship code to CIPD that uses generics.
+// Thus, we partition our common utilities (for now) until they are able to update.
+package util_generics
+
+// Get looks up an item in a map, returning a fallback value if absent.
+func Get[K comparable, V interface{}](theMap map[K]V, k K, fallback V) V {
+	if item, exists := theMap[k]; exists {
+		return item
+	}
+	return fallback
+}
diff --git a/go/util_generics/util_generics_test.go b/go/util_generics/util_generics_test.go
new file mode 100644
index 0000000..47d3b51
--- /dev/null
+++ b/go/util_generics/util_generics_test.go
@@ -0,0 +1,25 @@
+package util_generics
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"go.skia.org/infra/go/testutils/unittest"
+)
+
+func TestGet(t *testing.T) {
+	unittest.SmallTest(t)
+	someMap := map[string]int{
+		"one": 1,
+		"two": 2,
+	}
+	assert.Equal(t, 1, Get(someMap, "one", 99))           // key present
+	assert.Equal(t, 99, Get(someMap, "four billion", 99)) // key absent
+
+	anotherMap := map[string]string{
+		"one": "uno",
+		"two": "dos",
+	}
+	assert.Equal(t, "uno", Get(anotherMap, "one", "unknown"))              // key present
+	assert.Equal(t, "unknown", Get(anotherMap, "four billion", "unknown")) // key absent
+}
diff --git a/machine/go/test_machine_monitor/standalone/BUILD.bazel b/machine/go/test_machine_monitor/standalone/BUILD.bazel
index 84e0f2d..5032cc4 100644
--- a/machine/go/test_machine_monitor/standalone/BUILD.bazel
+++ b/machine/go/test_machine_monitor/standalone/BUILD.bazel
@@ -15,7 +15,7 @@
     deps = [
         "//go/skerr",
         "//go/sklog",
-        "//go/util",
+        "//go/util_generics",
         "@net_howett_plist//:plist",
     ] + select({
         "@io_bazel_rules_go//go/platform:darwin": [
diff --git a/machine/go/test_machine_monitor/standalone/gputable.go b/machine/go/test_machine_monitor/standalone/gputable.go
index 5b0dcf5..cb22d9b 100644
--- a/machine/go/test_machine_monitor/standalone/gputable.go
+++ b/machine/go/test_machine_monitor/standalone/gputable.go
@@ -4,7 +4,7 @@
 import (
 	"strings"
 
-	"go.skia.org/infra/go/util"
+	"go.skia.org/infra/go/util_generics"
 )
 
 type gpuVendorID string
@@ -113,5 +113,5 @@
 // gpuVendorNameToID returns the vendor ID for a given GPU vendor name. If unknown, returns "".
 func gpuVendorNameToID(name string) gpuVendorID {
 	// macOS 10.13 doesn't provide the vendor ID any more, so support reverse lookups on vendor name.
-	return util.Get(vendorNamesToIDs, strings.ToLower(name), "")
+	return util_generics.Get(vendorNamesToIDs, strings.ToLower(name), "")
 }