internal/goarch, internal/goos: update generators for syslist.go

Update the generator programs for the changes to syslist.go in CL
390274 and the changes to the generated files in CL 344955.

Tested by running the programs and verifying that the files did not
change.

Fixes #53299

Change-Id: I2b2c5769f7e9283aa05c803256d2ea1eb9ad1547
Reviewed-on: https://go-review.googlesource.com/c/go/+/411334
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/src/go/build/syslist.go b/src/go/build/syslist.go
index ea67662..35cffce 100644
--- a/src/go/build/syslist.go
+++ b/src/go/build/syslist.go
@@ -4,6 +4,10 @@
 
 package build
 
+// Note that this file is read by internal/goarch/gengoarch.go and by
+// internal/goos/gengoos.go. If you change this file, look at those
+// files as well.
+
 // knownOS is the list of past, present, and future known GOOS values.
 // Do not remove from this list, as it is used for filename matching.
 // If you add an entry to this list, look at unixOS, below.
diff --git a/src/internal/goarch/gengoarch.go b/src/internal/goarch/gengoarch.go
index 3c706e0..0b0be5c 100644
--- a/src/internal/goarch/gengoarch.go
+++ b/src/internal/goarch/gengoarch.go
@@ -11,7 +11,6 @@
 	"fmt"
 	"log"
 	"os"
-	"strconv"
 	"strings"
 )
 
@@ -22,14 +21,18 @@
 	if err != nil {
 		log.Fatal(err)
 	}
-	const goarchPrefix = `const goarchList = `
+	const goarchPrefix = `var knownArch = map[string]bool{`
+	inGOARCH := false
 	for _, line := range strings.Split(string(data), "\n") {
 		if strings.HasPrefix(line, goarchPrefix) {
-			text, err := strconv.Unquote(strings.TrimPrefix(line, goarchPrefix))
-			if err != nil {
-				log.Fatalf("parsing goarchList: %v", err)
-			}
-			goarches = strings.Fields(text)
+			inGOARCH = true
+		} else if inGOARCH && strings.HasPrefix(line, "}") {
+			break
+		} else if inGOARCH {
+			goarch := strings.Fields(line)[0]
+			goarch = strings.TrimPrefix(goarch, `"`)
+			goarch = strings.TrimSuffix(goarch, `":`)
+			goarches = append(goarches, goarch)
 		}
 	}
 
@@ -39,7 +42,7 @@
 		}
 		var buf bytes.Buffer
 		fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n")
-		fmt.Fprintf(&buf, "//go:build %s\n", target) // must explicitly include target for bootstrapping purposes
+		fmt.Fprintf(&buf, "//go:build %s\n\n", target) // must explicitly include target for bootstrapping purposes
 		fmt.Fprintf(&buf, "package goarch\n\n")
 		fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
 		for _, goarch := range goarches {
diff --git a/src/internal/goos/gengoos.go b/src/internal/goos/gengoos.go
index 1b62503..37d9706 100644
--- a/src/internal/goos/gengoos.go
+++ b/src/internal/goos/gengoos.go
@@ -11,7 +11,6 @@
 	"fmt"
 	"log"
 	"os"
-	"strconv"
 	"strings"
 )
 
@@ -22,14 +21,18 @@
 	if err != nil {
 		log.Fatal(err)
 	}
-	const goosPrefix = `const goosList = `
+	const goosPrefix = `var knownOS = map[string]bool{`
+	inGOOS := false
 	for _, line := range strings.Split(string(data), "\n") {
 		if strings.HasPrefix(line, goosPrefix) {
-			text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
-			if err != nil {
-				log.Fatalf("parsing goosList: %v", err)
-			}
-			gooses = strings.Fields(text)
+			inGOOS = true
+		} else if inGOOS && strings.HasPrefix(line, "}") {
+			break
+		} else if inGOOS {
+			goos := strings.Fields(line)[0]
+			goos = strings.TrimPrefix(goos, `"`)
+			goos = strings.TrimSuffix(goos, `":`)
+			gooses = append(gooses, goos)
 		}
 	}
 
@@ -50,7 +53,7 @@
 		tags = append(tags, target) // must explicitly include target for bootstrapping purposes
 		var buf bytes.Buffer
 		fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
-		fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
+		fmt.Fprintf(&buf, "//go:build %s\n\n", strings.Join(tags, " && "))
 		fmt.Fprintf(&buf, "package goos\n\n")
 		fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
 		for _, goos := range gooses {