protogen: use types.Universe.Names for list of builtin identifiers

Rather than maintaining our own list of builtin Go identifiers, use the
types.Universe API in the standard library instead.

It is okay if this list of names changes over time since we use this only
to derive a locally-used package name in the generated file.

Change-Id: Ib1688abc47d5c97b557f6e1f4d60c78e0951e65b
Reviewed-on: https://go-review.googlesource.com/c/157818
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/protogen/names.go b/protogen/names.go
index e291805..a1bddf7 100644
--- a/protogen/names.go
+++ b/protogen/names.go
@@ -83,48 +83,6 @@
 	return s
 }
 
-var isGoPredeclaredIdentifier = map[string]bool{
-	"append":     true,
-	"bool":       true,
-	"byte":       true,
-	"cap":        true,
-	"close":      true,
-	"complex":    true,
-	"complex128": true,
-	"complex64":  true,
-	"copy":       true,
-	"delete":     true,
-	"error":      true,
-	"false":      true,
-	"float32":    true,
-	"float64":    true,
-	"imag":       true,
-	"int":        true,
-	"int16":      true,
-	"int32":      true,
-	"int64":      true,
-	"int8":       true,
-	"iota":       true,
-	"len":        true,
-	"make":       true,
-	"new":        true,
-	"nil":        true,
-	"panic":      true,
-	"print":      true,
-	"println":    true,
-	"real":       true,
-	"recover":    true,
-	"rune":       true,
-	"string":     true,
-	"true":       true,
-	"uint":       true,
-	"uint16":     true,
-	"uint32":     true,
-	"uint64":     true,
-	"uint8":      true,
-	"uintptr":    true,
-}
-
 // baseName returns the last path element of the name, with the last dotted suffix removed.
 func baseName(name string) string {
 	// First, find the last element
diff --git a/protogen/protogen.go b/protogen/protogen.go
index 9c279b8..eb89cfa 100644
--- a/protogen/protogen.go
+++ b/protogen/protogen.go
@@ -19,6 +19,7 @@
 	"go/parser"
 	"go/printer"
 	"go/token"
+	"go/types"
 	"io/ioutil"
 	"os"
 	"path"
@@ -851,6 +852,12 @@
 		manualImports:    make(map[GoImportPath]bool),
 		annotations:      make(map[string][]Location),
 	}
+
+	// All predeclared identifiers in Go are already used.
+	for _, s := range types.Universe.Names() {
+		g.usedPackageNames[GoPackageName(s)] = true
+	}
+
 	gen.genFiles = append(gen.genFiles, g)
 	return g
 }
@@ -906,7 +913,7 @@
 		return string(packageName) + "." + ident.GoName
 	}
 	packageName := cleanPackageName(baseName(string(ident.GoImportPath)))
-	for i, orig := 1, packageName; g.usedPackageNames[packageName] || isGoPredeclaredIdentifier[string(packageName)]; i++ {
+	for i, orig := 1, packageName; g.usedPackageNames[packageName]; i++ {
 		packageName = orig + GoPackageName(strconv.Itoa(i))
 	}
 	g.packageNames[ident.GoImportPath] = packageName