internal/itoa, internal/runtime/strconv: delete

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>
This commit is contained in:
Russ Cox 2025-10-28 21:54:33 -04:00
parent b2a346bbd1
commit 49c1da474d
40 changed files with 104 additions and 395 deletions

View file

@ -55,7 +55,6 @@ var runtimePkgs = []string{
"internal/runtime/gc/scan", "internal/runtime/gc/scan",
"internal/runtime/maps", "internal/runtime/maps",
"internal/runtime/math", "internal/runtime/math",
"internal/runtime/strconv",
"internal/runtime/sys", "internal/runtime/sys",
"internal/runtime/syscall/linux", "internal/runtime/syscall/linux",
"internal/runtime/syscall/windows", "internal/runtime/syscall/windows",
@ -71,6 +70,7 @@ var runtimePkgs = []string{
"internal/goexperiment", "internal/goexperiment",
"internal/goos", "internal/goos",
"internal/profilerecord", "internal/profilerecord",
"internal/strconv",
"internal/stringslite", "internal/stringslite",
} }

View file

@ -87,7 +87,6 @@ var depsRules = `
structs structs
< internal/bytealg < internal/bytealg
< internal/stringslite < internal/stringslite
< internal/itoa
< internal/unsafeheader < internal/unsafeheader
< internal/race < internal/race
< internal/msan < internal/msan
@ -100,7 +99,6 @@ var depsRules = `
< internal/runtime/gc < internal/runtime/gc
< internal/runtime/math < internal/runtime/math
< internal/runtime/maps < internal/runtime/maps
< internal/runtime/strconv
< internal/runtime/cgroup < internal/runtime/cgroup
< internal/runtime/gc/scan < internal/runtime/gc/scan
< runtime < runtime
@ -301,7 +299,7 @@ var depsRules = `
FMT FMT
< text/template/parse; < text/template/parse;
internal/bytealg, internal/itoa, math/bits, slices, strconv, unique internal/bytealg, math/bits, slices, strconv, unique
< net/netip; < net/netip;
FMT, net/netip FMT, net/netip

View file

@ -63,12 +63,12 @@ var rtPkgs = [...]string{
"internal/runtime/exithook", "internal/runtime/exithook",
"internal/runtime/gc", "internal/runtime/gc",
"internal/runtime/math", "internal/runtime/math",
"internal/runtime/strconv",
"internal/runtime/sys", "internal/runtime/sys",
"internal/runtime/maps", "internal/runtime/maps",
"internal/runtime/syscall/linux", "internal/runtime/syscall/linux",
"internal/runtime/syscall/windows", "internal/runtime/syscall/windows",
"internal/runtime/cgroup", "internal/runtime/cgroup",
"internal/strconv",
"internal/stringslite", "internal/stringslite",
"runtime", "runtime",
} }

View file

@ -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:])
}

View file

@ -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)
}
}
}

View file

@ -5,7 +5,7 @@
package poll package poll
import ( import (
"internal/itoa" "internal/strconv"
"runtime" "runtime"
"sync" "sync"
"syscall" "syscall"
@ -72,7 +72,7 @@ func (aio *asyncIO) Cancel() {
if aio.pid == -1 { if aio.pid == -1 {
return 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 { if e != nil {
return return
} }

View file

@ -7,7 +7,7 @@
package poll package poll
import ( import (
"internal/itoa" "internal/strconv"
"internal/syscall/unix" "internal/syscall/unix"
"io" "io"
"sync/atomic" "sync/atomic"
@ -379,7 +379,7 @@ func (fd *FD) Write(p []byte) (int, error) {
// If we don't check this we will panic // If we don't check this we will panic
// with slice bounds out of range. // with slice bounds out of range.
// Use a more informative panic. // 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 nn += n
} }

View file

@ -6,8 +6,8 @@ package cgroup
import ( import (
"internal/bytealg" "internal/bytealg"
"internal/runtime/strconv"
"internal/runtime/syscall/linux" "internal/runtime/syscall/linux"
"internal/strconv"
) )
var ( var (
@ -220,8 +220,8 @@ func parseV1Number(buf []byte) (int64, error) {
} }
buf = buf[:i] buf = buf[:i]
val, ok := strconv.Atoi64(string(buf)) val, err := strconv.ParseInt(string(buf), 10, 64)
if !ok { if err != nil {
return 0, errMalformedFile return 0, errMalformedFile
} }
@ -280,13 +280,13 @@ func parseV2Limit(buf []byte) (float64, bool, error) {
} }
periodStr = periodStr[:i] periodStr = periodStr[:i]
quota, ok := strconv.Atoi64(string(quotaStr)) quota, err := strconv.ParseInt(string(quotaStr), 10, 64)
if !ok { if err != nil {
return 0, false, errMalformedFile return 0, false, errMalformedFile
} }
period, ok := strconv.Atoi64(string(periodStr)) period, err := strconv.ParseInt(string(periodStr), 10, 64)
if !ok { if err != nil {
return 0, false, errMalformedFile return 0, false, errMalformedFile
} }

View file

@ -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
}

View file

@ -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)
}
}
}

View file

@ -7,7 +7,7 @@ package net
import ( import (
"cmp" "cmp"
"internal/bytealg" "internal/bytealg"
"internal/itoa" "internal/strconv"
"slices" "slices"
_ "unsafe" // for go:linkname _ "unsafe" // for go:linkname
@ -36,7 +36,7 @@ func reverseaddr(addr string) (arpa string, err error) {
return "", &DNSError{Err: "unrecognized address", Name: addr} return "", &DNSError{Err: "unrecognized address", Name: addr}
} }
if ip.To4() != nil { 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 // Must be IPv6
buf := make([]byte, 0, len(ip)*4+len("ip6.arpa.")) buf := make([]byte, 0, len(ip)*4+len("ip6.arpa."))

View file

@ -17,7 +17,7 @@ import (
"errors" "errors"
"internal/bytealg" "internal/bytealg"
"internal/godebug" "internal/godebug"
"internal/itoa" "internal/strconv"
"internal/stringslite" "internal/stringslite"
"io" "io"
"os" "os"
@ -559,7 +559,7 @@ func (o hostLookupOrder) String() string {
if s, ok := lookupOrderName[o]; ok { if s, ok := lookupOrderName[o]; ok {
return s 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) { func (r *Resolver) goLookupHostOrder(ctx context.Context, name string, order hostLookupOrder, conf *dnsConfig) (addrs []string, err error) {

View file

@ -6,7 +6,7 @@ package net
import ( import (
"errors" "errors"
"internal/itoa" "internal/strconv"
"sync" "sync"
"time" "time"
_ "unsafe" _ "unsafe"
@ -246,7 +246,7 @@ func (zc *ipv6ZoneCache) name(index int) string {
zoneCache.RUnlock() zoneCache.RUnlock()
} }
if !ok { // last resort if !ok { // last resort
name = itoa.Uitoa(uint(index)) name = strconv.Itoa(index)
} }
return name return name
} }

View file

@ -6,7 +6,7 @@ package net
import ( import (
"errors" "errors"
"internal/itoa" "internal/strconv"
"internal/stringslite" "internal/stringslite"
"os" "os"
) )
@ -41,7 +41,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
func readInterface(i int) (*Interface, error) { func readInterface(i int) (*Interface, error) {
ifc := &Interface{ ifc := &Interface{
Index: i + 1, // Offset the index by one to suit the contract 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 Name: netdir + "/ipifc/" + strconv.Itoa(i), // Name is the full path to the interface path in plan9
} }
ifcstat := ifc.Name + "/status" ifcstat := ifc.Name + "/status"

View file

@ -14,7 +14,7 @@ package net
import ( import (
"internal/bytealg" "internal/bytealg"
"internal/itoa" "internal/strconv"
"internal/stringslite" "internal/stringslite"
"net/netip" "net/netip"
) )
@ -515,7 +515,7 @@ func (n *IPNet) String() string {
if l == -1 { if l == -1 {
return nn.String() + "/" + m.String() 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. // ParseIP parses s as an IP address, returning the result.

View file

@ -7,10 +7,9 @@ package net
import ( import (
"context" "context"
"internal/bytealg" "internal/bytealg"
"internal/itoa" "internal/strconv"
"io/fs" "io/fs"
"os" "os"
"strconv"
"syscall" "syscall"
) )
@ -338,9 +337,9 @@ func plan9LocalAddr(addr Addr) string {
if port == 0 { if port == 0 {
return "" 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 { func hangupCtlWrite(ctx context.Context, proto string, ctl *os.File, msg string) error {

View file

@ -8,7 +8,7 @@ import (
"context" "context"
"errors" "errors"
"internal/bytealg" "internal/bytealg"
"internal/itoa" "internal/strconv"
"internal/stringslite" "internal/stringslite"
"io" "io"
"os" "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() { if len(ip) != 0 && !ip.IsUnspecified() {
ips = ip.String() ips = ip.String()
} }
lines, err := queryCS(ctx, net, ips, itoa.Itoa(port)) lines, err := queryCS(ctx, net, ips, strconv.Itoa(port))
if err != nil { if err != nil {
return return
} }

View file

@ -16,7 +16,6 @@ import (
"errors" "errors"
"internal/bytealg" "internal/bytealg"
"internal/byteorder" "internal/byteorder"
"internal/itoa"
"math" "math"
"strconv" "strconv"
"unique" "unique"
@ -684,12 +683,12 @@ func (ip Addr) Prefix(b int) (Prefix, error) {
return Prefix{}, nil return Prefix{}, nil
case z4: case z4:
if b > 32 { 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 effectiveBits += 96
default: default:
if b > 128 { 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)) ip.addr = ip.addr.and(mask6(effectiveBits))
@ -1593,5 +1592,5 @@ func (p Prefix) String() string {
if !p.IsValid() { if !p.IsValid() {
return "invalid Prefix" return "invalid Prefix"
} }
return p.ip.String() + "/" + itoa.Itoa(p.Bits()) return p.ip.String() + "/" + strconv.Itoa(p.Bits())
} }

View file

@ -6,7 +6,7 @@ package net
import ( import (
"context" "context"
"internal/itoa" "internal/strconv"
"io" "io"
"net/netip" "net/netip"
"os" "os"
@ -47,9 +47,9 @@ func (a *TCPAddr) String() string {
} }
ip := ipEmptyString(a.IP) ip := ipEmptyString(a.IP)
if a.Zone != "" { 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 { func (a *TCPAddr) isWildcard() bool {

View file

@ -7,7 +7,7 @@
package net package net
import ( import (
"internal/itoa" "internal/strconv"
"syscall" "syscall"
"time" "time"
) )
@ -22,7 +22,7 @@ func setKeepAliveIdle(fd *netFD, d time.Duration) error {
return nil 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) _, e := fd.ctl.WriteAt([]byte(cmd), 0)
return e return e
} }

View file

@ -6,7 +6,7 @@ package net
import ( import (
"context" "context"
"internal/itoa" "internal/strconv"
"net/netip" "net/netip"
"syscall" "syscall"
) )
@ -47,9 +47,9 @@ func (a *UDPAddr) String() string {
} }
ip := ipEmptyString(a.IP) ip := ipEmptyString(a.IP)
if a.Zone != "" { 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 { func (a *UDPAddr) isWildcard() bool {

View file

@ -5,7 +5,7 @@
package os package os
import ( import (
"internal/itoa" "internal/strconv"
"syscall" "syscall"
"time" "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 { 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 { if e != nil {
return e return e
} }

View file

@ -7,7 +7,7 @@
package os package os
import ( import (
"internal/itoa" "internal/strconv"
"internal/syscall/execenv" "internal/syscall/execenv"
"runtime" "runtime"
"syscall" "syscall"
@ -132,16 +132,16 @@ func (p *ProcessState) String() string {
case status.Exited(): case status.Exited():
code := status.ExitStatus() code := status.ExitStatus()
if runtime.GOOS == "windows" && uint(code) >= 1<<16 { // windows uses large hex numbers 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 } else { // unix systems use small decimal integers
res = "exit status " + itoa.Itoa(code) // unix res = "exit status " + strconv.Itoa(code) // unix
} }
case status.Signaled(): case status.Signaled():
res = "signal: " + status.Signal().String() res = "signal: " + status.Signal().String()
case status.Stopped(): case status.Stopped():
res = "stop signal: " + status.StopSignal().String() res = "stop signal: " + status.StopSignal().String()
if status.StopSignal() == syscall.SIGTRAP && status.TrapCause() != 0 { if status.StopSignal() == syscall.SIGTRAP && status.TrapCause() != 0 {
res += " (trap " + itoa.Itoa(status.TrapCause()) + ")" res += " (trap " + strconv.Itoa(status.TrapCause()) + ")"
} }
case status.Continued(): case status.Continued():
res = "continued" res = "continued"

View file

@ -7,12 +7,12 @@
package os package os
import ( import (
"internal/itoa" "internal/strconv"
"syscall" "syscall"
) )
func executable() (string, error) { func executable() (string, error) {
fn := "/proc/" + itoa.Itoa(Getpid()) + "/text" fn := "/proc/" + strconv.Itoa(Getpid()) + "/text"
f, err := Open(fn) f, err := Open(fn)
if err != nil { if err != nil {
return "", err return "", err

View file

@ -5,7 +5,7 @@
package signal package signal
import ( import (
"internal/itoa" "internal/strconv"
"os" "os"
"runtime" "runtime"
"syscall" "syscall"
@ -157,7 +157,7 @@ func TestStop(t *testing.T) {
} }
func postNote(pid int, note string) error { 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 { if err != nil {
return err return err
} }

View file

@ -7,7 +7,7 @@ package os
import ( import (
"errors" "errors"
"internal/bytealg" "internal/bytealg"
"internal/itoa" "internal/strconv"
_ "unsafe" // for go:linkname _ "unsafe" // for go:linkname
) )
@ -20,7 +20,7 @@ import (
func runtime_rand() uint64 func runtime_rand() uint64
func nextRandom() string { 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, // CreateTemp creates a new temporary file in the directory dir,

View file

@ -8,7 +8,7 @@ import (
"errors" "errors"
"internal/abi" "internal/abi"
"internal/goarch" "internal/goarch"
"internal/itoa" "internal/strconv"
"internal/unsafeheader" "internal/unsafeheader"
"math" "math"
"runtime" "runtime"
@ -3573,7 +3573,7 @@ func cvtStringRunes(v Value, t Type) Value {
func cvtSliceArrayPtr(v Value, t Type) Value { func cvtSliceArrayPtr(v Value, t Type) Value {
n := t.Elem().Len() n := t.Elem().Len()
if n > v.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) h := (*unsafeheader.Slice)(v.ptr)
return Value{t.common(), h.Data, v.flag&^(flagIndir|flagAddr|flagKindMask) | flag(Pointer)} 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 { func cvtSliceArray(v Value, t Type) Value {
n := t.Len() n := t.Len()
if n > v.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) h := (*unsafeheader.Slice)(v.ptr)
typ := t.common() typ := t.common()

View file

@ -9,7 +9,7 @@ import (
"internal/goexperiment" "internal/goexperiment"
"internal/runtime/atomic" "internal/runtime/atomic"
"internal/runtime/math" "internal/runtime/math"
"internal/runtime/strconv" "internal/strconv"
_ "unsafe" // for go:linkname _ "unsafe" // for go:linkname
) )
@ -1313,8 +1313,8 @@ func readGOGC() int32 {
if p == "off" { if p == "off" {
return -1 return -1
} }
if n, ok := strconv.Atoi32(p); ok { if n, err := strconv.ParseInt(p, 10, 32); err == nil {
return n return int32(n)
} }
return 100 return 100
} }

View file

@ -8,8 +8,8 @@ import (
"internal/abi" "internal/abi"
"internal/goarch" "internal/goarch"
"internal/runtime/atomic" "internal/runtime/atomic"
"internal/runtime/strconv"
"internal/runtime/syscall/linux" "internal/runtime/syscall/linux"
"internal/strconv"
"unsafe" "unsafe"
) )
@ -339,8 +339,8 @@ func getHugePageSize() uintptr {
return 0 return 0
} }
n-- // remove trailing newline n-- // remove trailing newline
v, ok := strconv.Atoi(slicebytetostringtmp((*byte)(ptr), int(n))) v, err := strconv.Atoi(slicebytetostringtmp((*byte)(ptr), int(n)))
if !ok || v < 0 { if err != nil || v < 0 {
v = 0 v = 0
} }
if v&(v-1) != 0 { if v&(v-1) != 0 {

View file

@ -11,8 +11,8 @@ import (
"internal/goos" "internal/goos"
"internal/runtime/atomic" "internal/runtime/atomic"
"internal/runtime/exithook" "internal/runtime/exithook"
"internal/runtime/strconv"
"internal/runtime/sys" "internal/runtime/sys"
"internal/strconv"
"internal/stringslite" "internal/stringslite"
"unsafe" "unsafe"
) )
@ -918,8 +918,8 @@ func schedinit() {
lock(&sched.lock) lock(&sched.lock)
sched.lastpoll.Store(nanotime()) sched.lastpoll.Store(nanotime())
var procs int32 var procs int32
if n, ok := strconv.Atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 { if n, err := strconv.ParseInt(gogetenv("GOMAXPROCS"), 10, 32); err == nil && n > 0 {
procs = n procs = int32(n)
sched.customGOMAXPROCS = true sched.customGOMAXPROCS = true
} else { } else {
// Use numCPUStartup for initial GOMAXPROCS for two reasons: // Use numCPUStartup for initial GOMAXPROCS for two reasons:

View file

@ -8,7 +8,7 @@ import (
"internal/bytealg" "internal/bytealg"
"internal/goarch" "internal/goarch"
"internal/runtime/atomic" "internal/runtime/atomic"
"internal/runtime/strconv" "internal/strconv"
"unsafe" "unsafe"
) )
@ -532,17 +532,17 @@ func parsegodebug(godebug string, seen map[string]bool) {
// is int, not int32, and should only be updated // is int, not int32, and should only be updated
// if specified in GODEBUG. // if specified in GODEBUG.
if seen == nil && key == "memprofilerate" { if seen == nil && key == "memprofilerate" {
if n, ok := strconv.Atoi(value); ok { if n, err := strconv.Atoi(value); err == nil {
MemProfileRate = n MemProfileRate = n
} }
} else { } else {
for _, v := range dbgvars { for _, v := range dbgvars {
if v.name == key { 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 { if seen == nil && v.value != nil {
*v.value = n *v.value = int32(n)
} else if v.atomic != nil { } else if v.atomic != nil {
v.atomic.Store(n) v.atomic.Store(int32(n))
} }
} }
} }
@ -578,7 +578,7 @@ func setTraceback(level string) {
fallthrough fallthrough
default: default:
t = tracebackAll 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 t |= uint32(n) << tracebackShift
} }
} }

View file

@ -9,8 +9,8 @@ import (
"internal/bytealg" "internal/bytealg"
"internal/goarch" "internal/goarch"
"internal/runtime/math" "internal/runtime/math"
"internal/runtime/strconv"
"internal/runtime/sys" "internal/runtime/sys"
"internal/strconv"
"unsafe" "unsafe"
) )
@ -420,11 +420,11 @@ func parseByteCount(s string) (int64, bool) {
// Handle the easy non-suffix case. // Handle the easy non-suffix case.
last := s[len(s)-1] last := s[len(s)-1]
if last >= '0' && last <= '9' { if last >= '0' && last <= '9' {
n, ok := strconv.Atoi64(s) n, err := strconv.ParseInt(s, 10, 64)
if !ok || n < 0 { if err != nil || n < 0 {
return 0, false return 0, false
} }
return n, ok return n, true
} }
// Failing a trailing digit, this must always end in 'B'. // Failing a trailing digit, this must always end in 'B'.
// Also at this point there must be at least one digit before // 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'. // The one before that must always be a digit or 'i'.
if c := s[len(s)-2]; c >= '0' && c <= '9' { if c := s[len(s)-2]; c >= '0' && c <= '9' {
// Trivial 'B' suffix. // Trivial 'B' suffix.
n, ok := strconv.Atoi64(s[:len(s)-1]) n, err := strconv.ParseInt(s[:len(s)-1], 10, 64)
if !ok || n < 0 { if err != nil || n < 0 {
return 0, false return 0, false
} }
return n, ok return n, true
} else if c != 'i' { } else if c != 'i' {
return 0, false return 0, false
} }
@ -466,8 +466,8 @@ func parseByteCount(s string) (int64, bool) {
for i := 0; i < power; i++ { for i := 0; i < power; i++ {
m *= 1024 m *= 1024
} }
n, ok := strconv.Atoi64(s[:len(s)-3]) n, err := strconv.ParseInt(s[:len(s)-3], 10, 64)
if !ok || n < 0 { if err != nil || n < 0 {
return 0, false return 0, false
} }
un := uint64(n) un := uint64(n)

View file

@ -8,7 +8,7 @@ package syscall
import ( import (
errpkg "errors" errpkg "errors"
"internal/itoa" "internal/strconv"
"runtime" "runtime"
"unsafe" "unsafe"
) )
@ -681,7 +681,7 @@ childerror:
func formatIDMappings(idMap []SysProcIDMap) []byte { func formatIDMappings(idMap []SysProcIDMap) []byte {
var data []byte var data []byte
for _, im := range idMap { 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 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 // This is needed since kernel 3.19, because you can't write gid_map without
// disabling setgroups() system call. // disabling setgroups() system call.
func writeSetgroups(pid int, enable bool) error { 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) fd, err := Open(sgf, O_RDWR, 0)
if err != nil { if err != nil {
return err return err
@ -735,7 +735,7 @@ func writeSetgroups(pid int, enable bool) error {
// for a process and it is called from the parent process. // for a process and it is called from the parent process.
func writeUidGidMappings(pid int, sys *SysProcAttr) error { func writeUidGidMappings(pid int, sys *SysProcAttr) error {
if sys.UidMappings != nil { 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 { if err := writeIDMappings(uidf, sys.UidMappings); err != nil {
return err return err
} }
@ -746,7 +746,7 @@ func writeUidGidMappings(pid int, sys *SysProcAttr) error {
if err := writeSetgroups(pid, sys.GidMappingsEnableSetgroups); err != nil && err != ENOENT { if err := writeSetgroups(pid, sys.GidMappingsEnableSetgroups); err != nil && err != ENOENT {
return err return err
} }
gidf := "/proc/" + itoa.Itoa(pid) + "/gid_map" gidf := "/proc/" + strconv.Itoa(pid) + "/gid_map"
if err := writeIDMappings(gidf, sys.GidMappings); err != nil { if err := writeIDMappings(gidf, sys.GidMappings); err != nil {
return err return err
} }

View file

@ -7,7 +7,7 @@
package syscall package syscall
import ( import (
"internal/itoa" "internal/strconv"
"runtime" "runtime"
"sync" "sync"
"unsafe" "unsafe"
@ -327,7 +327,7 @@ func cexecPipe(p []int) error {
return e 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 { if e != nil {
Close(p[0]) Close(p[0])
Close(p[1]) Close(p[1])

View file

@ -8,8 +8,8 @@ package syscall
import ( import (
errorspkg "errors" errorspkg "errors"
"internal/itoa"
"internal/oserror" "internal/oserror"
"internal/strconv"
"sync" "sync"
"unsafe" "unsafe"
) )
@ -62,7 +62,7 @@ func (e Errno) Error() string {
return s return s
} }
} }
return "errno " + itoa.Itoa(int(e)) return "errno " + strconv.Itoa(int(e))
} }
func (e Errno) Is(target error) bool { func (e Errno) Is(target error) bool {
@ -110,7 +110,7 @@ func (s Signal) String() string {
return str return str
} }
} }
return "signal " + itoa.Itoa(int(s)) return "signal " + strconv.Itoa(int(s))
} }
var signals = [...]string{} var signals = [...]string{}

View file

@ -12,8 +12,8 @@
package syscall package syscall
import ( import (
"internal/itoa"
"internal/runtime/syscall/linux" "internal/runtime/syscall/linux"
"internal/strconv"
"runtime" "runtime"
"slices" "slices"
"unsafe" "unsafe"
@ -361,7 +361,7 @@ func Futimesat(dirfd int, path string, tv []Timeval) (err error) {
func Futimes(fd int, 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 // Believe it or not, this is the best we can do on Linux
// (and is what glibc does). // (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 const ImplementsGetwd = true

View file

@ -10,10 +10,10 @@ import (
errorspkg "errors" errorspkg "errors"
"internal/asan" "internal/asan"
"internal/bytealg" "internal/bytealg"
"internal/itoa"
"internal/msan" "internal/msan"
"internal/oserror" "internal/oserror"
"internal/race" "internal/race"
"internal/strconv"
"runtime" "runtime"
"sync" "sync"
"unsafe" "unsafe"
@ -114,7 +114,7 @@ func (e Errno) Error() string {
return s return s
} }
} }
return "errno " + itoa.Itoa(int(e)) return "errno " + strconv.Itoa(int(e))
} }
func (e Errno) Is(target error) bool { func (e Errno) Is(target error) bool {
@ -176,7 +176,7 @@ func (s Signal) String() string {
return str return str
} }
} }
return "signal " + itoa.Itoa(int(s)) return "signal " + strconv.Itoa(int(s))
} }
func Read(fd int, p []byte) (n int, err error) { func Read(fd int, p []byte) (n int, err error) {

View file

@ -8,8 +8,8 @@ package syscall
import ( import (
"errors" "errors"
"internal/itoa"
"internal/oserror" "internal/oserror"
"internal/strconv"
"unsafe" "unsafe"
) )
@ -71,7 +71,7 @@ func (e Errno) Error() string {
return s return s
} }
} }
return "errno " + itoa.Itoa(int(e)) return "errno " + strconv.Itoa(int(e))
} }
func (e Errno) Is(target error) bool { func (e Errno) Is(target error) bool {
@ -201,7 +201,7 @@ func (s Signal) String() string {
case SIGSYS: case SIGSYS:
return "bad system call" return "bad system call"
default: default:
return "signal " + itoa.Itoa(int(s)) return "signal " + strconv.Itoa(int(s))
} }
} }

View file

@ -10,10 +10,10 @@ import (
errorspkg "errors" errorspkg "errors"
"internal/asan" "internal/asan"
"internal/bytealg" "internal/bytealg"
"internal/itoa"
"internal/msan" "internal/msan"
"internal/oserror" "internal/oserror"
"internal/race" "internal/race"
"internal/strconv"
"sync" "sync"
"unsafe" "unsafe"
) )
@ -170,7 +170,7 @@ func (e Errno) error() string {
if err != nil { if err != nil {
n, err = formatMessage(flags, 0, uint32(e), 0, b, nil) n, err = formatMessage(flags, 0, uint32(e), 0, b, nil)
if err != nil { if err != nil {
return "winapi error #" + itoa.Itoa(int(e)) return "winapi error #" + strconv.Itoa(int(e))
} }
} }
// trim terminating \r and \n // trim terminating \r and \n
@ -1358,7 +1358,7 @@ func (s Signal) String() string {
return str return str
} }
} }
return "signal " + itoa.Itoa(int(s)) return "signal " + strconv.Itoa(int(s))
} }
func LoadCreateSymbolicLink() error { func LoadCreateSymbolicLink() error {

View file

@ -7,7 +7,7 @@
package time package time
import ( import (
"internal/itoa" "internal/strconv"
"syscall/js" "syscall/js"
) )
@ -36,10 +36,10 @@ func initLocal() {
} else { } else {
z.name += "+" z.name += "+"
} }
z.name += itoa.Itoa(offset / 60) z.name += strconv.Itoa(offset / 60)
min := offset % 60 min := offset % 60
if min != 0 { if min != 0 {
z.name += ":" + itoa.Itoa(min) z.name += ":" + strconv.Itoa(min)
} }
localLoc.zone = []zone{z} localLoc.zone = []zone{z}
} }