]> Cypherpunks repositories - gostls13.git/commitdiff
internal/itoa, internal/runtime/strconv: delete
authorRuss Cox <rsc@golang.org>
Wed, 29 Oct 2025 01:54:33 +0000 (21:54 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 29 Oct 2025 18:00:09 +0000 (11:00 -0700)
Replaced by internal/strconv.

Change-Id: I0656a9ad5075e60339e963fbae7d194d2f3e16be
Reviewed-on: https://go-review.googlesource.com/c/go/+/716001
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

40 files changed:
src/cmd/internal/objabi/pkgspecial.go
src/go/build/deps_test.go
src/internal/coverage/pkid.go
src/internal/itoa/itoa.go [deleted file]
src/internal/itoa/itoa_test.go [deleted file]
src/internal/poll/fd_io_plan9.go
src/internal/poll/fd_unix.go
src/internal/runtime/cgroup/cgroup_linux.go
src/internal/runtime/strconv/atoi.go [deleted file]
src/internal/runtime/strconv/atoi_test.go [deleted file]
src/net/dnsclient.go
src/net/dnsclient_unix.go
src/net/interface.go
src/net/interface_plan9.go
src/net/ip.go
src/net/ipsock_plan9.go
src/net/lookup_plan9.go
src/net/netip/netip.go
src/net/tcpsock.go
src/net/tcpsockopt_plan9.go
src/net/udpsock.go
src/os/exec_plan9.go
src/os/exec_posix.go
src/os/executable_plan9.go
src/os/signal/signal_plan9_test.go
src/os/tempfile.go
src/reflect/value.go
src/runtime/mgcpacer.go
src/runtime/os_linux.go
src/runtime/proc.go
src/runtime/runtime1.go
src/runtime/string.go
src/syscall/exec_linux.go
src/syscall/exec_plan9.go
src/syscall/syscall_js.go
src/syscall/syscall_linux.go
src/syscall/syscall_unix.go
src/syscall/syscall_wasip1.go
src/syscall/syscall_windows.go
src/time/zoneinfo_js.go

index 94efa6883bd3e34942fd8711e3ccd7d49cc04bca..bf30f0cc7faa07b7172e0b22f259a8d50210856a 100644 (file)
@@ -55,7 +55,6 @@ var runtimePkgs = []string{
        "internal/runtime/gc/scan",
        "internal/runtime/maps",
        "internal/runtime/math",
-       "internal/runtime/strconv",
        "internal/runtime/sys",
        "internal/runtime/syscall/linux",
        "internal/runtime/syscall/windows",
@@ -71,6 +70,7 @@ var runtimePkgs = []string{
        "internal/goexperiment",
        "internal/goos",
        "internal/profilerecord",
+       "internal/strconv",
        "internal/stringslite",
 }
 
index 10b27cfe927bac437e5705faba05edd29e78e03f..bc7eae69def15f894528b82f35857a88652ed994 100644 (file)
@@ -87,7 +87,6 @@ var depsRules = `
        structs
        < internal/bytealg
        < internal/stringslite
-       < internal/itoa
        < internal/unsafeheader
        < internal/race
        < internal/msan
@@ -100,7 +99,6 @@ var depsRules = `
        < internal/runtime/gc
        < internal/runtime/math
        < internal/runtime/maps
-       < internal/runtime/strconv
        < internal/runtime/cgroup
        < internal/runtime/gc/scan
        < runtime
@@ -301,7 +299,7 @@ var depsRules = `
        FMT
        < text/template/parse;
 
-       internal/bytealg, internal/itoa, math/bits, slices, strconv, unique
+       internal/bytealg, math/bits, slices, strconv, unique
        < net/netip;
 
        FMT, net/netip
index 09501e6bd2a62287664cf22713e875ad534be6a4..213a1ecfd15260a23fd148cc162dbb16fed53680 100644 (file)
@@ -63,12 +63,12 @@ var rtPkgs = [...]string{
        "internal/runtime/exithook",
        "internal/runtime/gc",
        "internal/runtime/math",
-       "internal/runtime/strconv",
        "internal/runtime/sys",
        "internal/runtime/maps",
        "internal/runtime/syscall/linux",
        "internal/runtime/syscall/windows",
        "internal/runtime/cgroup",
+       "internal/strconv",
        "internal/stringslite",
        "runtime",
 }
diff --git a/src/internal/itoa/itoa.go b/src/internal/itoa/itoa.go
deleted file mode 100644 (file)
index 4340ae0..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Simple conversions to avoid depending on strconv.
-
-package itoa
-
-// Itoa converts val to a decimal string.
-func Itoa(val int) string {
-       if val < 0 {
-               return "-" + Uitoa(uint(-val))
-       }
-       return Uitoa(uint(val))
-}
-
-// Uitoa converts val to a decimal string.
-func Uitoa(val uint) string {
-       if val == 0 { // avoid string allocation
-               return "0"
-       }
-       var buf [20]byte // big enough for 64bit value base 10
-       i := len(buf) - 1
-       for val >= 10 {
-               q := val / 10
-               buf[i] = byte('0' + val - q*10)
-               i--
-               val = q
-       }
-       // val < 10
-       buf[i] = byte('0' + val)
-       return string(buf[i:])
-}
-
-const hex = "0123456789abcdef"
-
-// Uitox converts val (a uint) to a hexadecimal string.
-func Uitox(val uint) string {
-       if val == 0 { // avoid string allocation
-               return "0x0"
-       }
-       var buf [20]byte // big enough for 64bit value base 16 + 0x
-       i := len(buf) - 1
-       for val >= 16 {
-               q := val / 16
-               buf[i] = hex[val%16]
-               i--
-               val = q
-       }
-       // val < 16
-       buf[i] = hex[val%16]
-       i--
-       buf[i] = 'x'
-       i--
-       buf[i] = '0'
-       return string(buf[i:])
-}
diff --git a/src/internal/itoa/itoa_test.go b/src/internal/itoa/itoa_test.go
deleted file mode 100644 (file)
index 8bed888..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package itoa_test
-
-import (
-       "fmt"
-       "internal/itoa"
-       "math"
-       "testing"
-)
-
-var (
-       minInt64  int64  = math.MinInt64
-       maxInt64  int64  = math.MaxInt64
-       maxUint64 uint64 = math.MaxUint64
-)
-
-func TestItoa(t *testing.T) {
-       tests := []int{int(minInt64), math.MinInt32, -999, -100, -1, 0, 1, 100, 999, math.MaxInt32, int(maxInt64)}
-       for _, tt := range tests {
-               got := itoa.Itoa(tt)
-               want := fmt.Sprint(tt)
-               if want != got {
-                       t.Fatalf("Itoa(%d) = %s, want %s", tt, got, want)
-               }
-       }
-}
-
-func TestUitoa(t *testing.T) {
-       tests := []uint{0, 1, 100, 999, math.MaxUint32, uint(maxUint64)}
-       for _, tt := range tests {
-               got := itoa.Uitoa(tt)
-               want := fmt.Sprint(tt)
-               if want != got {
-                       t.Fatalf("Uitoa(%d) = %s, want %s", tt, got, want)
-               }
-       }
-}
-
-func TestUitox(t *testing.T) {
-       tests := []uint{0, 1, 15, 100, 999, math.MaxUint32, uint(maxUint64)}
-       for _, tt := range tests {
-               got := itoa.Uitox(tt)
-               want := fmt.Sprintf("%#x", tt)
-               if want != got {
-                       t.Fatalf("Uitox(%x) = %s, want %s", tt, got, want)
-               }
-       }
-}
index 3205ac8513ee3966f08e2fe177bd0ba927bc057f..ab9ae13eb45a89f3d128d4eb0fd408c0ad437db1 100644 (file)
@@ -5,7 +5,7 @@
 package poll
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "runtime"
        "sync"
        "syscall"
@@ -72,7 +72,7 @@ func (aio *asyncIO) Cancel() {
        if aio.pid == -1 {
                return
        }
-       f, e := syscall.Open("/proc/"+itoa.Itoa(aio.pid)+"/note", syscall.O_WRONLY)
+       f, e := syscall.Open("/proc/"+strconv.Itoa(aio.pid)+"/note", syscall.O_WRONLY)
        if e != nil {
                return
        }
index 31e6e21120fde3e8fb7ce8c269ebf342312c758b..f56173524d721cd7f2e68899061a8e31183811d0 100644 (file)
@@ -7,7 +7,7 @@
 package poll
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "internal/syscall/unix"
        "io"
        "sync/atomic"
@@ -379,7 +379,7 @@ func (fd *FD) Write(p []byte) (int, error) {
                                // If we don't check this we will panic
                                // with slice bounds out of range.
                                // Use a more informative panic.
-                               panic("invalid return from write: got " + itoa.Itoa(n) + " from a write of " + itoa.Itoa(max-nn))
+                               panic("invalid return from write: got " + strconv.Itoa(n) + " from a write of " + strconv.Itoa(max-nn))
                        }
                        nn += n
                }
index 91815b4a1d0df88dcee191c10f29ab092182ba01..7b35a9bc18773204cb74a50869af31d1899cc86c 100644 (file)
@@ -6,8 +6,8 @@ package cgroup
 
 import (
        "internal/bytealg"
-       "internal/runtime/strconv"
        "internal/runtime/syscall/linux"
+       "internal/strconv"
 )
 
 var (
@@ -220,8 +220,8 @@ func parseV1Number(buf []byte) (int64, error) {
        }
        buf = buf[:i]
 
-       val, ok := strconv.Atoi64(string(buf))
-       if !ok {
+       val, err := strconv.ParseInt(string(buf), 10, 64)
+       if err != nil {
                return 0, errMalformedFile
        }
 
@@ -280,13 +280,13 @@ func parseV2Limit(buf []byte) (float64, bool, error) {
        }
        periodStr = periodStr[:i]
 
-       quota, ok := strconv.Atoi64(string(quotaStr))
-       if !ok {
+       quota, err := strconv.ParseInt(string(quotaStr), 10, 64)
+       if err != nil {
                return 0, false, errMalformedFile
        }
 
-       period, ok := strconv.Atoi64(string(periodStr))
-       if !ok {
+       period, err := strconv.ParseInt(string(periodStr), 10, 64)
+       if err != nil {
                return 0, false, errMalformedFile
        }
 
diff --git a/src/internal/runtime/strconv/atoi.go b/src/internal/runtime/strconv/atoi.go
deleted file mode 100644 (file)
index 0308757..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2025 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package strconv
-
-import (
-       "internal/runtime/math"
-)
-
-// Atoi64 parses an int64 from a string s.
-// The bool result reports whether s is a number
-// representable by a value of type int64.
-func Atoi64(s string) (int64, bool) {
-       if s == "" {
-               return 0, false
-       }
-
-       neg := false
-       if s[0] == '-' {
-               neg = true
-               s = s[1:]
-       }
-
-       un := uint64(0)
-       for i := 0; i < len(s); i++ {
-               c := s[i]
-               if c < '0' || c > '9' {
-                       return 0, false
-               }
-               if un > math.MaxUint64/10 {
-                       // overflow
-                       return 0, false
-               }
-               un *= 10
-               un1 := un + uint64(c) - '0'
-               if un1 < un {
-                       // overflow
-                       return 0, false
-               }
-               un = un1
-       }
-
-       if !neg && un > uint64(math.MaxInt64) {
-               return 0, false
-       }
-       if neg && un > uint64(math.MaxInt64)+1 {
-               return 0, false
-       }
-
-       n := int64(un)
-       if neg {
-               n = -n
-       }
-
-       return n, true
-}
-
-// Atoi is like Atoi64 but for integers
-// that fit into an int.
-func Atoi(s string) (int, bool) {
-       if n, ok := Atoi64(s); n == int64(int(n)) {
-               return int(n), ok
-       }
-       return 0, false
-}
-
-// Atoi32 is like Atoi but for integers
-// that fit into an int32.
-func Atoi32(s string) (int32, bool) {
-       if n, ok := Atoi64(s); n == int64(int32(n)) {
-               return int32(n), ok
-       }
-       return 0, false
-}
diff --git a/src/internal/runtime/strconv/atoi_test.go b/src/internal/runtime/strconv/atoi_test.go
deleted file mode 100644 (file)
index 71a8030..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2025 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package strconv_test
-
-import (
-       "internal/runtime/strconv"
-       "testing"
-)
-
-const intSize = 32 << (^uint(0) >> 63)
-
-type atoi64Test struct {
-       in  string
-       out int64
-       ok  bool
-}
-
-var atoi64tests = []atoi64Test{
-       {"", 0, false},
-       {"0", 0, true},
-       {"-0", 0, true},
-       {"1", 1, true},
-       {"-1", -1, true},
-       {"12345", 12345, true},
-       {"-12345", -12345, true},
-       {"012345", 12345, true},
-       {"-012345", -12345, true},
-       {"12345x", 0, false},
-       {"-12345x", 0, false},
-       {"98765432100", 98765432100, true},
-       {"-98765432100", -98765432100, true},
-       {"20496382327982653440", 0, false},
-       {"-20496382327982653440", 0, false},
-       {"9223372036854775807", 1<<63 - 1, true},
-       {"-9223372036854775807", -(1<<63 - 1), true},
-       {"9223372036854775808", 0, false},
-       {"-9223372036854775808", -1 << 63, true},
-       {"9223372036854775809", 0, false},
-       {"-9223372036854775809", 0, false},
-}
-
-func TestAtoi(t *testing.T) {
-       switch intSize {
-       case 32:
-               for i := range atoi32tests {
-                       test := &atoi32tests[i]
-                       out, ok := strconv.Atoi(test.in)
-                       if test.out != int32(out) || test.ok != ok {
-                               t.Errorf("Atoi(%q) = (%v, %v) want (%v, %v)",
-                                       test.in, out, ok, test.out, test.ok)
-                       }
-               }
-       case 64:
-               for i := range atoi64tests {
-                       test := &atoi64tests[i]
-                       out, ok := strconv.Atoi(test.in)
-                       if test.out != int64(out) || test.ok != ok {
-                               t.Errorf("Atoi(%q) = (%v, %v) want (%v, %v)",
-                                       test.in, out, ok, test.out, test.ok)
-                       }
-               }
-       }
-}
-
-type atoi32Test struct {
-       in  string
-       out int32
-       ok  bool
-}
-
-var atoi32tests = []atoi32Test{
-       {"", 0, false},
-       {"0", 0, true},
-       {"-0", 0, true},
-       {"1", 1, true},
-       {"-1", -1, true},
-       {"12345", 12345, true},
-       {"-12345", -12345, true},
-       {"012345", 12345, true},
-       {"-012345", -12345, true},
-       {"12345x", 0, false},
-       {"-12345x", 0, false},
-       {"987654321", 987654321, true},
-       {"-987654321", -987654321, true},
-       {"2147483647", 1<<31 - 1, true},
-       {"-2147483647", -(1<<31 - 1), true},
-       {"2147483648", 0, false},
-       {"-2147483648", -1 << 31, true},
-       {"2147483649", 0, false},
-       {"-2147483649", 0, false},
-}
-
-func TestAtoi32(t *testing.T) {
-       for i := range atoi32tests {
-               test := &atoi32tests[i]
-               out, ok := strconv.Atoi32(test.in)
-               if test.out != out || test.ok != ok {
-                       t.Errorf("Atoi32(%q) = (%v, %v) want (%v, %v)",
-                               test.in, out, ok, test.out, test.ok)
-               }
-       }
-}
index 5f135cc211738dd8edac5e01bf7e4bade99bfd8e..eb509d175fc1a0a53a0c68162802d688bb25b5ab 100644 (file)
@@ -7,7 +7,7 @@ package net
 import (
        "cmp"
        "internal/bytealg"
-       "internal/itoa"
+       "internal/strconv"
        "slices"
        _ "unsafe" // for go:linkname
 
@@ -36,7 +36,7 @@ func reverseaddr(addr string) (arpa string, err error) {
                return "", &DNSError{Err: "unrecognized address", Name: addr}
        }
        if ip.To4() != nil {
-               return itoa.Uitoa(uint(ip[15])) + "." + itoa.Uitoa(uint(ip[14])) + "." + itoa.Uitoa(uint(ip[13])) + "." + itoa.Uitoa(uint(ip[12])) + ".in-addr.arpa.", nil
+               return strconv.Itoa(int(ip[15])) + "." + strconv.Itoa(int(ip[14])) + "." + strconv.Itoa(int(ip[13])) + "." + strconv.Itoa(int(ip[12])) + ".in-addr.arpa.", nil
        }
        // Must be IPv6
        buf := make([]byte, 0, len(ip)*4+len("ip6.arpa."))
index 940fcccf7f2139749f9caf01c4670eb206488de4..40f76062944f465fc05e7c2d690477565a261e5c 100644 (file)
@@ -17,7 +17,7 @@ import (
        "errors"
        "internal/bytealg"
        "internal/godebug"
-       "internal/itoa"
+       "internal/strconv"
        "internal/stringslite"
        "io"
        "os"
@@ -559,7 +559,7 @@ func (o hostLookupOrder) String() string {
        if s, ok := lookupOrderName[o]; ok {
                return s
        }
-       return "hostLookupOrder=" + itoa.Itoa(int(o)) + "??"
+       return "hostLookupOrder=" + strconv.Itoa(int(o)) + "??"
 }
 
 func (r *Resolver) goLookupHostOrder(ctx context.Context, name string, order hostLookupOrder, conf *dnsConfig) (addrs []string, err error) {
index b6057780c4a98ff467f7f3bd275df7ad0a4997d6..5ae3a3a149d95453544d809533a0a233cf6fcdcb 100644 (file)
@@ -6,7 +6,7 @@ package net
 
 import (
        "errors"
-       "internal/itoa"
+       "internal/strconv"
        "sync"
        "time"
        _ "unsafe"
@@ -246,7 +246,7 @@ func (zc *ipv6ZoneCache) name(index int) string {
                zoneCache.RUnlock()
        }
        if !ok { // last resort
-               name = itoa.Uitoa(uint(index))
+               name = strconv.Itoa(index)
        }
        return name
 }
index 93c783b56eec6e6c72293dbcef22185b467018f4..88f1325ab22039970f9ef80666f4c327aa658eda 100644 (file)
@@ -6,7 +6,7 @@ package net
 
 import (
        "errors"
-       "internal/itoa"
+       "internal/strconv"
        "internal/stringslite"
        "os"
 )
@@ -40,8 +40,8 @@ func interfaceTable(ifindex int) ([]Interface, error) {
 
 func readInterface(i int) (*Interface, error) {
        ifc := &Interface{
-               Index: i + 1,                             // Offset the index by one to suit the contract
-               Name:  netdir + "/ipifc/" + itoa.Itoa(i), // Name is the full path to the interface path in plan9
+               Index: i + 1,                                // Offset the index by one to suit the contract
+               Name:  netdir + "/ipifc/" + strconv.Itoa(i), // Name is the full path to the interface path in plan9
        }
 
        ifcstat := ifc.Name + "/status"
index e3ee6ca70a32dcb98973b38b6057aadb90e3d7db..7d58e89e112786d8b38cdb1db85d6ed73afc6601 100644 (file)
@@ -14,7 +14,7 @@ package net
 
 import (
        "internal/bytealg"
-       "internal/itoa"
+       "internal/strconv"
        "internal/stringslite"
        "net/netip"
 )
@@ -515,7 +515,7 @@ func (n *IPNet) String() string {
        if l == -1 {
                return nn.String() + "/" + m.String()
        }
-       return nn.String() + "/" + itoa.Uitoa(uint(l))
+       return nn.String() + "/" + strconv.Itoa(l)
 }
 
 // ParseIP parses s as an IP address, returning the result.
index 6ae9cf3cc105f0acd33eb864f53bd7da3b599262..2bd5071d56a598f61ba53d0348fd2a174135ddb4 100644 (file)
@@ -7,10 +7,9 @@ package net
 import (
        "context"
        "internal/bytealg"
-       "internal/itoa"
+       "internal/strconv"
        "io/fs"
        "os"
-       "strconv"
        "syscall"
 )
 
@@ -338,9 +337,9 @@ func plan9LocalAddr(addr Addr) string {
                if port == 0 {
                        return ""
                }
-               return itoa.Itoa(port)
+               return strconv.Itoa(port)
        }
-       return ip.String() + "!" + itoa.Itoa(port)
+       return ip.String() + "!" + strconv.Itoa(port)
 }
 
 func hangupCtlWrite(ctx context.Context, proto string, ctl *os.File, msg string) error {
index c9bab29aded7bad45106f78f375053831d8015a8..836beb3b17158b06e454a8848e4f842d0a7c28a2 100644 (file)
@@ -8,7 +8,7 @@ import (
        "context"
        "errors"
        "internal/bytealg"
-       "internal/itoa"
+       "internal/strconv"
        "internal/stringslite"
        "io"
        "os"
@@ -87,7 +87,7 @@ func queryCS1(ctx context.Context, net string, ip IP, port int) (clone, dest str
        if len(ip) != 0 && !ip.IsUnspecified() {
                ips = ip.String()
        }
-       lines, err := queryCS(ctx, net, ips, itoa.Itoa(port))
+       lines, err := queryCS(ctx, net, ips, strconv.Itoa(port))
        if err != nil {
                return
        }
index b1b15b47287de28c90cc93281452627fa2401c23..10882db6a41a43348b7e11703d7b11aa03d2e1c5 100644 (file)
@@ -16,7 +16,6 @@ import (
        "errors"
        "internal/bytealg"
        "internal/byteorder"
-       "internal/itoa"
        "math"
        "strconv"
        "unique"
@@ -684,12 +683,12 @@ func (ip Addr) Prefix(b int) (Prefix, error) {
                return Prefix{}, nil
        case z4:
                if b > 32 {
-                       return Prefix{}, errors.New("prefix length " + itoa.Itoa(b) + " too large for IPv4")
+                       return Prefix{}, errors.New("prefix length " + strconv.Itoa(b) + " too large for IPv4")
                }
                effectiveBits += 96
        default:
                if b > 128 {
-                       return Prefix{}, errors.New("prefix length " + itoa.Itoa(b) + " too large for IPv6")
+                       return Prefix{}, errors.New("prefix length " + strconv.Itoa(b) + " too large for IPv6")
                }
        }
        ip.addr = ip.addr.and(mask6(effectiveBits))
@@ -1593,5 +1592,5 @@ func (p Prefix) String() string {
        if !p.IsValid() {
                return "invalid Prefix"
        }
-       return p.ip.String() + "/" + itoa.Itoa(p.Bits())
+       return p.ip.String() + "/" + strconv.Itoa(p.Bits())
 }
index 376bf238c70d0710948f0b78c953bd6f3f521192..35eda25ead07c541bf5efb8775bbc75b69824efb 100644 (file)
@@ -6,7 +6,7 @@ package net
 
 import (
        "context"
-       "internal/itoa"
+       "internal/strconv"
        "io"
        "net/netip"
        "os"
@@ -47,9 +47,9 @@ func (a *TCPAddr) String() string {
        }
        ip := ipEmptyString(a.IP)
        if a.Zone != "" {
-               return JoinHostPort(ip+"%"+a.Zone, itoa.Itoa(a.Port))
+               return JoinHostPort(ip+"%"+a.Zone, strconv.Itoa(a.Port))
        }
-       return JoinHostPort(ip, itoa.Itoa(a.Port))
+       return JoinHostPort(ip, strconv.Itoa(a.Port))
 }
 
 func (a *TCPAddr) isWildcard() bool {
index 017e87518aeb9157ab83cdd1738612c7dea45157..4c7958b8bde9395fddbed15264a8648c98536840 100644 (file)
@@ -7,7 +7,7 @@
 package net
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "syscall"
        "time"
 )
@@ -22,7 +22,7 @@ func setKeepAliveIdle(fd *netFD, d time.Duration) error {
                return nil
        }
 
-       cmd := "keepalive " + itoa.Itoa(int(d/time.Millisecond))
+       cmd := "keepalive " + strconv.Itoa(int(d/time.Millisecond))
        _, e := fd.ctl.WriteAt([]byte(cmd), 0)
        return e
 }
index f9a3bee867d340cd318722b97081e125a4fa5260..fcd6a065688b9e40b2a2ad326282d2fd1e888ba4 100644 (file)
@@ -6,7 +6,7 @@ package net
 
 import (
        "context"
-       "internal/itoa"
+       "internal/strconv"
        "net/netip"
        "syscall"
 )
@@ -47,9 +47,9 @@ func (a *UDPAddr) String() string {
        }
        ip := ipEmptyString(a.IP)
        if a.Zone != "" {
-               return JoinHostPort(ip+"%"+a.Zone, itoa.Itoa(a.Port))
+               return JoinHostPort(ip+"%"+a.Zone, strconv.Itoa(a.Port))
        }
-       return JoinHostPort(ip, itoa.Itoa(a.Port))
+       return JoinHostPort(ip, strconv.Itoa(a.Port))
 }
 
 func (a *UDPAddr) isWildcard() bool {
index a3d363b344061fbdccdb588e4f7444022ef51de7..7d50ab26287c273110181ed49d8f3a79a5ef42f4 100644 (file)
@@ -5,7 +5,7 @@
 package os
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "syscall"
        "time"
 )
@@ -40,7 +40,7 @@ func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e
 }
 
 func (p *Process) writeProcFile(file string, data string) error {
-       f, e := OpenFile("/proc/"+itoa.Itoa(p.Pid)+"/"+file, O_WRONLY, 0)
+       f, e := OpenFile("/proc/"+strconv.Itoa(p.Pid)+"/"+file, O_WRONLY, 0)
        if e != nil {
                return e
        }
index 6b6977ab7855911b12eead430435932ae0428e1f..9f83db1555a3a48a1bfd24c6a009cef00907670b 100644 (file)
@@ -7,7 +7,7 @@
 package os
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "internal/syscall/execenv"
        "runtime"
        "syscall"
@@ -132,16 +132,16 @@ func (p *ProcessState) String() string {
        case status.Exited():
                code := status.ExitStatus()
                if runtime.GOOS == "windows" && uint(code) >= 1<<16 { // windows uses large hex numbers
-                       res = "exit status " + itoa.Uitox(uint(code))
+                       res = "exit status 0x" + strconv.FormatUint(uint64(code), 16)
                } else { // unix systems use small decimal integers
-                       res = "exit status " + itoa.Itoa(code) // unix
+                       res = "exit status " + strconv.Itoa(code) // unix
                }
        case status.Signaled():
                res = "signal: " + status.Signal().String()
        case status.Stopped():
                res = "stop signal: " + status.StopSignal().String()
                if status.StopSignal() == syscall.SIGTRAP && status.TrapCause() != 0 {
-                       res += " (trap " + itoa.Itoa(status.TrapCause()) + ")"
+                       res += " (trap " + strconv.Itoa(status.TrapCause()) + ")"
                }
        case status.Continued():
                res = "continued"
index 8d8c83260f59ca6601be1499cedd522fd76b8fea..fcb269665bcf716eaf233499972ff3ad139dc62a 100644 (file)
@@ -7,12 +7,12 @@
 package os
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "syscall"
 )
 
 func executable() (string, error) {
-       fn := "/proc/" + itoa.Itoa(Getpid()) + "/text"
+       fn := "/proc/" + strconv.Itoa(Getpid()) + "/text"
        f, err := Open(fn)
        if err != nil {
                return "", err
index 8357199aa4ad64749d70a48eb9b48a2ac41c7f65..1d76cfcaaa6c2b5eb23672e2bc6338c906e3be0d 100644 (file)
@@ -5,7 +5,7 @@
 package signal
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "os"
        "runtime"
        "syscall"
@@ -157,7 +157,7 @@ func TestStop(t *testing.T) {
 }
 
 func postNote(pid int, note string) error {
-       f, err := os.OpenFile("/proc/"+itoa.Itoa(pid)+"/note", os.O_WRONLY, 0)
+       f, err := os.OpenFile("/proc/"+strconv.Itoa(pid)+"/note", os.O_WRONLY, 0)
        if err != nil {
                return err
        }
index 428dc965b7a01792e20ca2b3d02ecc0ac52a4307..085423805faec9f8c2791b39ae19241cb8b4f4db 100644 (file)
@@ -7,7 +7,7 @@ package os
 import (
        "errors"
        "internal/bytealg"
-       "internal/itoa"
+       "internal/strconv"
        _ "unsafe" // for go:linkname
 )
 
@@ -20,7 +20,7 @@ import (
 func runtime_rand() uint64
 
 func nextRandom() string {
-       return itoa.Uitoa(uint(uint32(runtime_rand())))
+       return strconv.FormatUint(uint64(uint32(runtime_rand())), 10)
 }
 
 // CreateTemp creates a new temporary file in the directory dir,
index c0ac45de77be85d939132dfb63f6f1192dd9f5a3..b5d5aa8bf2e8a38bdc7705581296ad851ef99da9 100644 (file)
@@ -8,7 +8,7 @@ import (
        "errors"
        "internal/abi"
        "internal/goarch"
-       "internal/itoa"
+       "internal/strconv"
        "internal/unsafeheader"
        "math"
        "runtime"
@@ -3573,7 +3573,7 @@ func cvtStringRunes(v Value, t Type) Value {
 func cvtSliceArrayPtr(v Value, t Type) Value {
        n := t.Elem().Len()
        if n > v.Len() {
-               panic("reflect: cannot convert slice with length " + itoa.Itoa(v.Len()) + " to pointer to array with length " + itoa.Itoa(n))
+               panic("reflect: cannot convert slice with length " + strconv.Itoa(v.Len()) + " to pointer to array with length " + strconv.Itoa(n))
        }
        h := (*unsafeheader.Slice)(v.ptr)
        return Value{t.common(), h.Data, v.flag&^(flagIndir|flagAddr|flagKindMask) | flag(Pointer)}
@@ -3583,7 +3583,7 @@ func cvtSliceArrayPtr(v Value, t Type) Value {
 func cvtSliceArray(v Value, t Type) Value {
        n := t.Len()
        if n > v.Len() {
-               panic("reflect: cannot convert slice with length " + itoa.Itoa(v.Len()) + " to array with length " + itoa.Itoa(n))
+               panic("reflect: cannot convert slice with length " + strconv.Itoa(v.Len()) + " to array with length " + strconv.Itoa(n))
        }
        h := (*unsafeheader.Slice)(v.ptr)
        typ := t.common()
index 17e2f405e4829686282713d77abea0234ffd85de..bd454b5ceaba4cd62a6616bbaa377c87b26da8f8 100644 (file)
@@ -9,7 +9,7 @@ import (
        "internal/goexperiment"
        "internal/runtime/atomic"
        "internal/runtime/math"
-       "internal/runtime/strconv"
+       "internal/strconv"
        _ "unsafe" // for go:linkname
 )
 
@@ -1313,8 +1313,8 @@ func readGOGC() int32 {
        if p == "off" {
                return -1
        }
-       if n, ok := strconv.Atoi32(p); ok {
-               return n
+       if n, err := strconv.ParseInt(p, 10, 32); err == nil {
+               return int32(n)
        }
        return 100
 }
index 1b7d5731cc32abce861433f788b36fe6020148c1..7e6af22d48a764c42fb83556641a49b19017afcb 100644 (file)
@@ -8,8 +8,8 @@ import (
        "internal/abi"
        "internal/goarch"
        "internal/runtime/atomic"
-       "internal/runtime/strconv"
        "internal/runtime/syscall/linux"
+       "internal/strconv"
        "unsafe"
 )
 
@@ -339,8 +339,8 @@ func getHugePageSize() uintptr {
                return 0
        }
        n-- // remove trailing newline
-       v, ok := strconv.Atoi(slicebytetostringtmp((*byte)(ptr), int(n)))
-       if !ok || v < 0 {
+       v, err := strconv.Atoi(slicebytetostringtmp((*byte)(ptr), int(n)))
+       if err != nil || v < 0 {
                v = 0
        }
        if v&(v-1) != 0 {
index 36949fb2cf06817a076248a3f1bdda20629d04df..6c16effc954a2bfe313e32538860f128f7c9dbd3 100644 (file)
@@ -11,8 +11,8 @@ import (
        "internal/goos"
        "internal/runtime/atomic"
        "internal/runtime/exithook"
-       "internal/runtime/strconv"
        "internal/runtime/sys"
+       "internal/strconv"
        "internal/stringslite"
        "unsafe"
 )
@@ -918,8 +918,8 @@ func schedinit() {
        lock(&sched.lock)
        sched.lastpoll.Store(nanotime())
        var procs int32
-       if n, ok := strconv.Atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 {
-               procs = n
+       if n, err := strconv.ParseInt(gogetenv("GOMAXPROCS"), 10, 32); err == nil && n > 0 {
+               procs = int32(n)
                sched.customGOMAXPROCS = true
        } else {
                // Use numCPUStartup for initial GOMAXPROCS for two reasons:
index 15b546783b5e53cdacd16be9e7540ffcedd5c6ca..3ec5c44ebd843813bf3b0bbe388ffc392222f077 100644 (file)
@@ -8,7 +8,7 @@ import (
        "internal/bytealg"
        "internal/goarch"
        "internal/runtime/atomic"
-       "internal/runtime/strconv"
+       "internal/strconv"
        "unsafe"
 )
 
@@ -532,17 +532,17 @@ func parsegodebug(godebug string, seen map[string]bool) {
                // is int, not int32, and should only be updated
                // if specified in GODEBUG.
                if seen == nil && key == "memprofilerate" {
-                       if n, ok := strconv.Atoi(value); ok {
+                       if n, err := strconv.Atoi(value); err == nil {
                                MemProfileRate = n
                        }
                } else {
                        for _, v := range dbgvars {
                                if v.name == key {
-                                       if n, ok := strconv.Atoi32(value); ok {
+                                       if n, err := strconv.ParseInt(value, 10, 32); err == nil {
                                                if seen == nil && v.value != nil {
-                                                       *v.value = n
+                                                       *v.value = int32(n)
                                                } else if v.atomic != nil {
-                                                       v.atomic.Store(n)
+                                                       v.atomic.Store(int32(n))
                                                }
                                        }
                                }
@@ -578,7 +578,7 @@ func setTraceback(level string) {
                fallthrough
        default:
                t = tracebackAll
-               if n, ok := strconv.Atoi(level); ok && n == int(uint32(n)) {
+               if n, err := strconv.Atoi(level); err == nil && n == int(uint32(n)) {
                        t |= uint32(n) << tracebackShift
                }
        }
index 3726d9235bfa4b6eac91cfc5c4ce99ed4a14c460..15b3868cbc0fc68fc3269fb5f19f9e243fd20ae6 100644 (file)
@@ -9,8 +9,8 @@ import (
        "internal/bytealg"
        "internal/goarch"
        "internal/runtime/math"
-       "internal/runtime/strconv"
        "internal/runtime/sys"
+       "internal/strconv"
        "unsafe"
 )
 
@@ -420,11 +420,11 @@ func parseByteCount(s string) (int64, bool) {
        // Handle the easy non-suffix case.
        last := s[len(s)-1]
        if last >= '0' && last <= '9' {
-               n, ok := strconv.Atoi64(s)
-               if !ok || n < 0 {
+               n, err := strconv.ParseInt(s, 10, 64)
+               if err != nil || n < 0 {
                        return 0, false
                }
-               return n, ok
+               return n, true
        }
        // Failing a trailing digit, this must always end in 'B'.
        // Also at this point there must be at least one digit before
@@ -435,11 +435,11 @@ func parseByteCount(s string) (int64, bool) {
        // The one before that must always be a digit or 'i'.
        if c := s[len(s)-2]; c >= '0' && c <= '9' {
                // Trivial 'B' suffix.
-               n, ok := strconv.Atoi64(s[:len(s)-1])
-               if !ok || n < 0 {
+               n, err := strconv.ParseInt(s[:len(s)-1], 10, 64)
+               if err != nil || n < 0 {
                        return 0, false
                }
-               return n, ok
+               return n, true
        } else if c != 'i' {
                return 0, false
        }
@@ -466,8 +466,8 @@ func parseByteCount(s string) (int64, bool) {
        for i := 0; i < power; i++ {
                m *= 1024
        }
-       n, ok := strconv.Atoi64(s[:len(s)-3])
-       if !ok || n < 0 {
+       n, err := strconv.ParseInt(s[:len(s)-3], 10, 64)
+       if err != nil || n < 0 {
                return 0, false
        }
        un := uint64(n)
index 14c13e273a49831a67014a64f4947d84ffe99a14..73582d0aea0de25490b3a8d1e2d7d876bc512532 100644 (file)
@@ -8,7 +8,7 @@ package syscall
 
 import (
        errpkg "errors"
-       "internal/itoa"
+       "internal/strconv"
        "runtime"
        "unsafe"
 )
@@ -681,7 +681,7 @@ childerror:
 func formatIDMappings(idMap []SysProcIDMap) []byte {
        var data []byte
        for _, im := range idMap {
-               data = append(data, itoa.Itoa(im.ContainerID)+" "+itoa.Itoa(im.HostID)+" "+itoa.Itoa(im.Size)+"\n"...)
+               data = append(data, strconv.Itoa(im.ContainerID)+" "+strconv.Itoa(im.HostID)+" "+strconv.Itoa(im.Size)+"\n"...)
        }
        return data
 }
@@ -710,7 +710,7 @@ func writeIDMappings(path string, idMap []SysProcIDMap) error {
 // This is needed since kernel 3.19, because you can't write gid_map without
 // disabling setgroups() system call.
 func writeSetgroups(pid int, enable bool) error {
-       sgf := "/proc/" + itoa.Itoa(pid) + "/setgroups"
+       sgf := "/proc/" + strconv.Itoa(pid) + "/setgroups"
        fd, err := Open(sgf, O_RDWR, 0)
        if err != nil {
                return err
@@ -735,7 +735,7 @@ func writeSetgroups(pid int, enable bool) error {
 // for a process and it is called from the parent process.
 func writeUidGidMappings(pid int, sys *SysProcAttr) error {
        if sys.UidMappings != nil {
-               uidf := "/proc/" + itoa.Itoa(pid) + "/uid_map"
+               uidf := "/proc/" + strconv.Itoa(pid) + "/uid_map"
                if err := writeIDMappings(uidf, sys.UidMappings); err != nil {
                        return err
                }
@@ -746,7 +746,7 @@ func writeUidGidMappings(pid int, sys *SysProcAttr) error {
                if err := writeSetgroups(pid, sys.GidMappingsEnableSetgroups); err != nil && err != ENOENT {
                        return err
                }
-               gidf := "/proc/" + itoa.Itoa(pid) + "/gid_map"
+               gidf := "/proc/" + strconv.Itoa(pid) + "/gid_map"
                if err := writeIDMappings(gidf, sys.GidMappings); err != nil {
                        return err
                }
index 91705e175edc2b3cd418006f944d78891090dca5..f0481e8bf095b9699ff5c90436e3d6f4cba4f1ca 100644 (file)
@@ -7,7 +7,7 @@
 package syscall
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "runtime"
        "sync"
        "unsafe"
@@ -327,7 +327,7 @@ func cexecPipe(p []int) error {
                return e
        }
 
-       fd, e := Open("#d/"+itoa.Itoa(p[1]), O_RDWR|O_CLOEXEC)
+       fd, e := Open("#d/"+strconv.Itoa(p[1]), O_RDWR|O_CLOEXEC)
        if e != nil {
                Close(p[0])
                Close(p[1])
index c320e34f2601cb0f922137ac908f955601d9de78..bb8d70b73d393b2365b0c436ab6ea685909a9094 100644 (file)
@@ -8,8 +8,8 @@ package syscall
 
 import (
        errorspkg "errors"
-       "internal/itoa"
        "internal/oserror"
+       "internal/strconv"
        "sync"
        "unsafe"
 )
@@ -62,7 +62,7 @@ func (e Errno) Error() string {
                        return s
                }
        }
-       return "errno " + itoa.Itoa(int(e))
+       return "errno " + strconv.Itoa(int(e))
 }
 
 func (e Errno) Is(target error) bool {
@@ -110,7 +110,7 @@ func (s Signal) String() string {
                        return str
                }
        }
-       return "signal " + itoa.Itoa(int(s))
+       return "signal " + strconv.Itoa(int(s))
 }
 
 var signals = [...]string{}
index ec9f771daad93ee136af650a99695749f3a981d8..9418bd849415368088414558f354cd1ce61c748a 100644 (file)
@@ -12,8 +12,8 @@
 package syscall
 
 import (
-       "internal/itoa"
        "internal/runtime/syscall/linux"
+       "internal/strconv"
        "runtime"
        "slices"
        "unsafe"
@@ -361,7 +361,7 @@ func Futimesat(dirfd int, path string, tv []Timeval) (err error) {
 func Futimes(fd int, tv []Timeval) (err error) {
        // Believe it or not, this is the best we can do on Linux
        // (and is what glibc does).
-       return Utimes("/proc/self/fd/"+itoa.Itoa(fd), tv)
+       return Utimes("/proc/self/fd/"+strconv.Itoa(fd), tv)
 }
 
 const ImplementsGetwd = true
index 7de2272b591b9500780c3d0925528e20644452a7..d957b77dc41f7640bbd8bfe7f06a863587c4f1f2 100644 (file)
@@ -10,10 +10,10 @@ import (
        errorspkg "errors"
        "internal/asan"
        "internal/bytealg"
-       "internal/itoa"
        "internal/msan"
        "internal/oserror"
        "internal/race"
+       "internal/strconv"
        "runtime"
        "sync"
        "unsafe"
@@ -114,7 +114,7 @@ func (e Errno) Error() string {
                        return s
                }
        }
-       return "errno " + itoa.Itoa(int(e))
+       return "errno " + strconv.Itoa(int(e))
 }
 
 func (e Errno) Is(target error) bool {
@@ -176,7 +176,7 @@ func (s Signal) String() string {
                        return str
                }
        }
-       return "signal " + itoa.Itoa(int(s))
+       return "signal " + strconv.Itoa(int(s))
 }
 
 func Read(fd int, p []byte) (n int, err error) {
index c9225293a0cc3107a7f2165413b08bbb066b7ef6..9b5f502e30ebd5c82182ac78a1b80e40cd330037 100644 (file)
@@ -8,8 +8,8 @@ package syscall
 
 import (
        "errors"
-       "internal/itoa"
        "internal/oserror"
+       "internal/strconv"
        "unsafe"
 )
 
@@ -71,7 +71,7 @@ func (e Errno) Error() string {
                        return s
                }
        }
-       return "errno " + itoa.Itoa(int(e))
+       return "errno " + strconv.Itoa(int(e))
 }
 
 func (e Errno) Is(target error) bool {
@@ -201,7 +201,7 @@ func (s Signal) String() string {
        case SIGSYS:
                return "bad system call"
        default:
-               return "signal " + itoa.Itoa(int(s))
+               return "signal " + strconv.Itoa(int(s))
        }
 }
 
index f86f03e20f0a0fdc605c62d4e07430bed1deabf9..817eeb681134956e5f0cb918132feaadbe3c790f 100644 (file)
@@ -10,10 +10,10 @@ import (
        errorspkg "errors"
        "internal/asan"
        "internal/bytealg"
-       "internal/itoa"
        "internal/msan"
        "internal/oserror"
        "internal/race"
+       "internal/strconv"
        "sync"
        "unsafe"
 )
@@ -170,7 +170,7 @@ func (e Errno) error() string {
        if err != nil {
                n, err = formatMessage(flags, 0, uint32(e), 0, b, nil)
                if err != nil {
-                       return "winapi error #" + itoa.Itoa(int(e))
+                       return "winapi error #" + strconv.Itoa(int(e))
                }
        }
        // trim terminating \r and \n
@@ -1358,7 +1358,7 @@ func (s Signal) String() string {
                        return str
                }
        }
-       return "signal " + itoa.Itoa(int(s))
+       return "signal " + strconv.Itoa(int(s))
 }
 
 func LoadCreateSymbolicLink() error {
index 8da34a21fbae0a6f7d4b78fd9857150d05ada91f..11d944a9049a9e5d78057fc395f41e45a3896c2b 100644 (file)
@@ -7,7 +7,7 @@
 package time
 
 import (
-       "internal/itoa"
+       "internal/strconv"
        "syscall/js"
 )
 
@@ -36,10 +36,10 @@ func initLocal() {
        } else {
                z.name += "+"
        }
-       z.name += itoa.Itoa(offset / 60)
+       z.name += strconv.Itoa(offset / 60)
        min := offset % 60
        if min != 0 {
-               z.name += ":" + itoa.Itoa(min)
+               z.name += ":" + strconv.Itoa(min)
        }
        localLoc.zone = []zone{z}
 }