From d682a9dfbe14d86c0d4c5b7841bfd2509cdd478f Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Sat, 14 Sep 2024 10:09:58 +0000 Subject: [PATCH] net/netip: use const for max address length Makes it consistent with other code in net/netip, also constants are visible through LSP hover, which makes it easier to see the size. Change-Id: I3d02c860ac3c61cc037eaca5418297f78698c3f8 GitHub-Last-Rev: 785a8d58c372f5e1faa2e43dd1991d7040e36603 GitHub-Pull-Request: golang/go#69468 Reviewed-on: https://go-review.googlesource.com/c/go/+/613356 LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/net/netip/netip.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index a1e93cb29b..82c0501139 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.go @@ -974,16 +974,16 @@ func (ip Addr) MarshalText() ([]byte, error) { case z0: return []byte(""), nil case z4: - max := len("255.255.255.255") + const max = len("255.255.255.255") b := make([]byte, 0, max) return ip.appendTo4(b), nil default: if ip.Is4In6() { - max := len("::ffff:255.255.255.255%enp5s0") + const max = len("::ffff:255.255.255.255%enp5s0") b := make([]byte, 0, max) return ip.appendTo4In6(b), nil } - max := len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0") + const max = len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0") b := make([]byte, 0, max) return ip.appendTo6(b), nil }