]> Cypherpunks repositories - gostls13.git/commitdiff
net/netip: unexport fields of addrDetail
authorIan Lance Taylor <iant@golang.org>
Sun, 23 Jun 2024 22:21:28 +0000 (15:21 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 24 Jun 2024 15:28:52 +0000 (15:28 +0000)
For #68113

Change-Id: I19c7d8eff8e3a7a1b6c8e28cb867edeca6be237d
Reviewed-on: https://go-review.googlesource.com/c/go/+/593737
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/netip/export_test.go
src/net/netip/netip.go
src/net/netip/netip_test.go

index 4febcad89365446886660d7728ae7debed323161..b2fae1aa47eedc2c9fcdfe38af20b2bf2495b42e 100644 (file)
@@ -16,6 +16,10 @@ type Uint128 = uint128
 
 type AddrDetail = addrDetail
 
+func MakeAddrDetail(isV6 bool, zoneV6 string) AddrDetail {
+       return AddrDetail{isV6: isV6, zoneV6: zoneV6}
+}
+
 func Mk128(hi, lo uint64) Uint128 {
        return uint128{hi, lo}
 }
index 57063eeb718a27e447ffe9d6f5310b3d4885ac82..a1e93cb29bfbd9427f51debc43f89df841d8bd74 100644 (file)
@@ -59,8 +59,8 @@ type Addr struct {
 
 // addrDetail represents the details of an Addr, like address family and IPv6 zone.
 type addrDetail struct {
-       IsV6   bool   // IPv4 is false, IPv6 is true.
-       ZoneV6 string // != "" only if IsV6 is true.
+       isV6   bool   // IPv4 is false, IPv6 is true.
+       zoneV6 string // != "" only if IsV6 is true.
 }
 
 // z0, z4, and z6noz are sentinel Addr.z values.
@@ -68,7 +68,7 @@ type addrDetail struct {
 var (
        z0    unique.Handle[addrDetail]
        z4    = unique.Make(addrDetail{})
-       z6noz = unique.Make(addrDetail{IsV6: true})
+       z6noz = unique.Make(addrDetail{isV6: true})
 )
 
 // IPv6LinkLocalAllNodes returns the IPv6 link-local all nodes multicast
@@ -410,7 +410,7 @@ func (ip Addr) Zone() string {
        if ip.z == z0 {
                return ""
        }
-       return ip.z.Value().ZoneV6
+       return ip.z.Value().zoneV6
 }
 
 // Compare returns an integer comparing two IPs.
@@ -495,7 +495,7 @@ func (ip Addr) WithZone(zone string) Addr {
                ip.z = z6noz
                return ip
        }
-       ip.z = unique.Make(addrDetail{IsV6: true, ZoneV6: zone})
+       ip.z = unique.Make(addrDetail{isV6: true, zoneV6: zone})
        return ip
 }
 
index ad0e7542082a23c962c605a627ca6120e8fce0a1..94c70f2290ea4f5fe35cd533383dea56820378fb 100644 (file)
@@ -112,18 +112,18 @@ func TestParseAddr(t *testing.T) {
                // IPv6 with a zone specifier.
                {
                        in: "fd7a:115c:a1e0:ab12:4843:cd96:626b:430b%eth0",
-                       ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth0"})),
+                       ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), unique.Make(MakeAddrDetail(true, "eth0"))),
                },
                // IPv6 with dotted decimal and zone specifier.
                {
                        in:  "1:2::ffff:192.168.140.255%eth1",
-                       ip:  MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"})),
+                       ip:  MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), unique.Make(MakeAddrDetail(true, "eth1"))),
                        str: "1:2::ffff:c0a8:8cff%eth1",
                },
                // 4-in-6 with zone
                {
                        in:  "::ffff:192.168.140.255%eth1",
-                       ip:  MkAddr(Mk128(0, 0x0000ffffc0a88cff), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"})),
+                       ip:  MkAddr(Mk128(0, 0x0000ffffc0a88cff), unique.Make(MakeAddrDetail(true, "eth1"))),
                        str: "::ffff:192.168.140.255%eth1",
                },
                // IPv6 with capital letters.
@@ -1723,7 +1723,7 @@ var parseBenchInputs = []struct {
 }
 
 func BenchmarkParseAddr(b *testing.B) {
-       sinkInternValue = unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"}) // Pin to not benchmark the intern package
+       sinkInternValue = unique.Make(MakeAddrDetail(true, "eth1")) // Pin to not benchmark the intern package
        for _, test := range parseBenchInputs {
                b.Run(test.name, func(b *testing.B) {
                        b.ReportAllocs()