internal/fetch: remove explicit goexperiment.jsonv2 enabling for encoding/json Since goexperiment.jsonv2 is enabled by default in Go 1.27, we don't need to explicitly enable it for "encoding/json" in matchingFiles. It will be inherited from the toolchain defaults when running on Go 1.27+. This avoids incorrectly enabling it when processing encoding/json package doc of older Go versions unnecessarily. Updates golang/go#71488 Fixes golang/go#80325 Change-Id: I341de2f0571d7cc9c4045b806285bcede9d8853c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/803341 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/fetch/load.go b/internal/fetch/load.go index b1437c4..74073ea 100644 --- a/internal/fetch/load.go +++ b/internal/fetch/load.go
@@ -452,7 +452,7 @@ } switch importPath { - case "encoding/json", "encoding/json/v2", "encoding/json/jsontext": + case "encoding/json/v2", "encoding/json/jsontext": bctx.ToolTags = append(bctx.ToolTags, "goexperiment.jsonv2") case "runtime/secret": bctx.ToolTags = append(bctx.ToolTags, "goexperiment.runtimesecret")
diff --git a/internal/fetch/load_test.go b/internal/fetch/load_test.go index 36c7150..e2114b8 100644 --- a/internal/fetch/load_test.go +++ b/internal/fetch/load_test.go
@@ -68,6 +68,13 @@ otherWant["other_jsonv2.go"] = []byte(otherJSONv2Body) } + jsonWant := map[string][]byte{ + "plain.go": []byte(plainGoBody), + } + if slices.Contains(build.Default.ToolTags, "goexperiment.jsonv2") { + jsonWant["json.go"] = []byte(jsonv2Body) + } + for _, test := range []struct { name string goos, goarch string @@ -115,10 +122,7 @@ goarch: "amd64", importPath: "encoding/json", contents: jsonv2Contents, - want: map[string][]byte{ - "plain.go": []byte(plainGoBody), - "json.go": []byte(jsonv2Body), - }, + want: jsonWant, }, { name: "jsonv2",