all: prepare for Unicode 15.0.0 internal/gen has never been updated for Go 1.17's //go:build tags. Do that, and add the entry for Unicode 15.0.0. Unicode 15.0.0 will change 9fff to be a CJK ideograph, which will break the unicode/runenames example test. Delete that part of the example. For golang/go#55079. Change-Id: I12b0c6d031d6d6e1970c8fe6eb5453fa64c9f365 Reviewed-on: https://go-review.googlesource.com/c/text/+/503035 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
diff --git a/internal/gen/gen.go b/internal/gen/gen.go index 268258d..faa7092 100644 --- a/internal/gen/gen.go +++ b/internal/gen/gen.go
@@ -87,7 +87,8 @@ {"10.0.0", "go1.10,!go1.13"}, {"11.0.0", "go1.13,!go1.14"}, {"12.0.0", "go1.14,!go1.16"}, - {"13.0.0", "go1.16"}, + {"13.0.0", "go1.16,!go1.21"}, + {"15.0.0", "go1.21"}, } // buildTags reports the build tags used for the current Unicode version. @@ -276,6 +277,13 @@ return fmt.Sprint(prefix, "%s", suffix) } +// tagLines returns the //go:build and // +build lines to add to the file. +func tagLines(tags string) string { + newTags := strings.ReplaceAll(tags, ",", " && ") + return "//go:build " + newTags + "\n" + + "// +build " + tags + "\n" +} + func updateBuildTags(pattern string) { for _, t := range tags { oldFile := fmt.Sprintf(pattern, t.version) @@ -283,8 +291,7 @@ if err != nil { continue } - build := fmt.Sprintf("// +build %s", t.buildTags) - b = regexp.MustCompile(`// \+build .*`).ReplaceAll(b, []byte(build)) + b = regexp.MustCompile(`((//go:build|// \+build).*\n)+`).ReplaceAll(b, []byte(tagLines(t.buildTags))) err = os.WriteFile(oldFile, b, 0644) if err != nil { log.Fatal(err) @@ -316,7 +323,8 @@ func WriteGo(w io.Writer, pkg, tags string, b []byte) (n int, err error) { src := []byte(header) if tags != "" { - src = append(src, fmt.Sprintf("// +build %s\n\n", tags)...) + src = append(src, tagLines(tags)...) + src = append(src, '\n') } src = append(src, fmt.Sprintf("package %s\n\n", pkg)...) src = append(src, b...)
diff --git a/unicode/runenames/example_test.go b/unicode/runenames/example_test.go index 70e2251..1503c28 100644 --- a/unicode/runenames/example_test.go +++ b/unicode/runenames/example_test.go
@@ -41,7 +41,6 @@ '\U00004dc0', '\U00009fd5', - '\U00009fff', '\U0000a000', 0xdc00, // '\U0000dc00' (Low Surrogate) is an invalid Go literal. '\U0000f800', @@ -94,7 +93,6 @@ // 00003402 "<CJK Ideograph Extension A>" // 00004dc0 "HEXAGRAM FOR THE CREATIVE HEAVEN" // 00009fd5 "<CJK Ideograph>" - // 00009fff "" // 0000a000 "YI SYLLABLE IT" // 0000dc00 "<Low Surrogate>" // 0000f800 "<Private Use>"