From e54965ed5ec6d172b7c3913ed67449e34dfb6843 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 22 Apr 2026 11:38:51 +0200 Subject: [PATCH] net: use internal/itoa for Go < 1.26 to fix build with older Go versions internal/strconv was added in Go 1.26. For older Go versions, use internal/itoa (already present in TinyGo) via a build tag shim. Fixes TinyGo #5332 Signed-off-by: deadprogram --- ip.go | 3 +-- itoa_go126.go | 7 +++++++ itoa_pre126.go | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 itoa_go126.go create mode 100644 itoa_pre126.go diff --git a/ip.go b/ip.go index 75390bf..c969241 100644 --- a/ip.go +++ b/ip.go @@ -14,7 +14,6 @@ package net import ( "internal/bytealg" - "internal/strconv" "internal/stringslite" "net/netip" ) @@ -515,7 +514,7 @@ func (n *IPNet) String() string { if l == -1 { return nn.String() + "/" + m.String() } - return nn.String() + "/" + strconv.Itoa(l) + return nn.String() + "/" + netItoa(l) } // ParseIP parses s as an IP address, returning the result. diff --git a/itoa_go126.go b/itoa_go126.go new file mode 100644 index 0000000..68e8a7c --- /dev/null +++ b/itoa_go126.go @@ -0,0 +1,7 @@ +//go:build go1.26 + +package net + +import "internal/strconv" + +func netItoa(i int) string { return strconv.Itoa(i) } diff --git a/itoa_pre126.go b/itoa_pre126.go new file mode 100644 index 0000000..1398256 --- /dev/null +++ b/itoa_pre126.go @@ -0,0 +1,7 @@ +//go:build !go1.26 + +package net + +import "internal/itoa" + +func netItoa(i int) string { return itoa.Itoa(i) }