summaryrefslogtreecommitdiffhomepage
path: root/types/netmap/netmap.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2025-10-28 15:23:47 -0700
committerJoe Tsai <joetsai@digital-static.net>2025-11-05 15:51:03 -0800
commitc299a96624e7b9c1667084361b79a0e0b132993a (patch)
tree029bb026ebb94082eb3827bc4df845719e1b2e96 /types/netmap/netmap.go
parent77123a569ba1055f091db06e2d1b59c09b02f108 (diff)
downloadtailscale-dsnet/jsonimports-ci.tar.xz
tailscale-dsnet/jsonimports-ci.zip
all: apply consistent imports of "json" packagesdsnet/jsonimports-ci
This runs: go run ./cmd/jsonimports -update -ignore=tempfork/ which applies the following rules: * Until the Go standard library formally accepts "encoding/json/v2" and "encoding/json/jsontext" into the standard library (i.e., they are no longer considered experimental), we forbid any code from directly importing those packages. Go code should instead import "github.com/go-json-experiment/json" and "github.com/go-json-experiment/json/jsontext". The latter packages contain aliases to the standard library if built on Go 1.25 with the goexperiment.jsonv2 tag specified. * Imports of "encoding/json" or "github.com/go-json-experiment/json/v1" must be explicitly imported under the package name "jsonv1". If both packages need to be imported, then the former should be imported under the package name "jsonv1std". * Imports of "github.com/go-json-experiment/json" must be explicitly imported under the package name "jsonv2". The latter two rules exist to provide clarity when reading code. Without them, it is unclear whether "json.Marshal" refers to v1 or v2. With them, however, it is clear that "jsonv1.Marshal" is calling v1 and that "jsonv2.Marshal" is calling v2. Updates tailscale/corp#791 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Diffstat (limited to 'types/netmap/netmap.go')
-rw-r--r--types/netmap/netmap.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/types/netmap/netmap.go b/types/netmap/netmap.go
index cc6bec1db..ad13c2928 100644
--- a/types/netmap/netmap.go
+++ b/types/netmap/netmap.go
@@ -6,7 +6,7 @@ package netmap
import (
"cmp"
- "encoding/json"
+ jsonv1 "encoding/json"
"fmt"
"net/netip"
"sort"
@@ -438,7 +438,7 @@ func (b *NetworkMap) ConciseDiffFrom(a *NetworkMap) string {
}
func (nm *NetworkMap) JSON() string {
- b, err := json.MarshalIndent(*nm, "", " ")
+ b, err := jsonv1.MarshalIndent(*nm, "", " ")
if err != nil {
return fmt.Sprintf("[json error: %v]", err)
}