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>
"internal/runtime/gc/scan",
"internal/runtime/maps",
"internal/runtime/math",
- "internal/runtime/strconv",
"internal/runtime/sys",
"internal/runtime/syscall/linux",
"internal/runtime/syscall/windows",
"internal/goexperiment",
"internal/goos",
"internal/profilerecord",
+ "internal/strconv",
"internal/stringslite",
}
structs
< internal/bytealg
< internal/stringslite
- < internal/itoa
< internal/unsafeheader
< internal/race
< internal/msan
< internal/runtime/gc
< internal/runtime/math
< internal/runtime/maps
- < internal/runtime/strconv
< internal/runtime/cgroup
< internal/runtime/gc/scan
< runtime
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
"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",
}
+++ /dev/null
-// 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:])
-}
+++ /dev/null
-// 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)
- }
- }
-}
package poll
import (
- "internal/itoa"
+ "internal/strconv"
"runtime"
"sync"
"syscall"
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
}
package poll
import (
- "internal/itoa"
+ "internal/strconv"
"internal/syscall/unix"
"io"
"sync/atomic"
// 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
}
import (
"internal/bytealg"
- "internal/runtime/strconv"
"internal/runtime/syscall/linux"
+ "internal/strconv"
)
var (
}
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
}
}
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
}
+++ /dev/null
-// 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
-}
+++ /dev/null
-// 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)
- }
- }
-}
import (
"cmp"
"internal/bytealg"
- "internal/itoa"
+ "internal/strconv"
"slices"
_ "unsafe" // for go:linkname
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."))
"errors"
"internal/bytealg"
"internal/godebug"
- "internal/itoa"
+ "internal/strconv"
"internal/stringslite"
"io"
"os"
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) {
import (
"errors"
- "internal/itoa"
+ "internal/strconv"
"sync"
"time"
_ "unsafe"
zoneCache.RUnlock()
}
if !ok { // last resort
- name = itoa.Uitoa(uint(index))
+ name = strconv.Itoa(index)
}
return name
}
import (
"errors"
- "internal/itoa"
+ "internal/strconv"
"internal/stringslite"
"os"
)
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"
import (
"internal/bytealg"
- "internal/itoa"
+ "internal/strconv"
"internal/stringslite"
"net/netip"
)
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.
import (
"context"
"internal/bytealg"
- "internal/itoa"
+ "internal/strconv"
"io/fs"
"os"
- "strconv"
"syscall"
)
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 {
"context"
"errors"
"internal/bytealg"
- "internal/itoa"
+ "internal/strconv"
"internal/stringslite"
"io"
"os"
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
}
"errors"
"internal/bytealg"
"internal/byteorder"
- "internal/itoa"
"math"
"strconv"
"unique"
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))
if !p.IsValid() {
return "invalid Prefix"
}
- return p.ip.String() + "/" + itoa.Itoa(p.Bits())
+ return p.ip.String() + "/" + strconv.Itoa(p.Bits())
}
import (
"context"
- "internal/itoa"
+ "internal/strconv"
"io"
"net/netip"
"os"
}
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 {
package net
import (
- "internal/itoa"
+ "internal/strconv"
"syscall"
"time"
)
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
}
import (
"context"
- "internal/itoa"
+ "internal/strconv"
"net/netip"
"syscall"
)
}
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 {
package os
import (
- "internal/itoa"
+ "internal/strconv"
"syscall"
"time"
)
}
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
}
package os
import (
- "internal/itoa"
+ "internal/strconv"
"internal/syscall/execenv"
"runtime"
"syscall"
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"
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
package signal
import (
- "internal/itoa"
+ "internal/strconv"
"os"
"runtime"
"syscall"
}
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
}
import (
"errors"
"internal/bytealg"
- "internal/itoa"
+ "internal/strconv"
_ "unsafe" // for go:linkname
)
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,
"errors"
"internal/abi"
"internal/goarch"
- "internal/itoa"
+ "internal/strconv"
"internal/unsafeheader"
"math"
"runtime"
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)}
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()
"internal/goexperiment"
"internal/runtime/atomic"
"internal/runtime/math"
- "internal/runtime/strconv"
+ "internal/strconv"
_ "unsafe" // for go:linkname
)
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
}
"internal/abi"
"internal/goarch"
"internal/runtime/atomic"
- "internal/runtime/strconv"
"internal/runtime/syscall/linux"
+ "internal/strconv"
"unsafe"
)
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 {
"internal/goos"
"internal/runtime/atomic"
"internal/runtime/exithook"
- "internal/runtime/strconv"
"internal/runtime/sys"
+ "internal/strconv"
"internal/stringslite"
"unsafe"
)
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:
"internal/bytealg"
"internal/goarch"
"internal/runtime/atomic"
- "internal/runtime/strconv"
+ "internal/strconv"
"unsafe"
)
// 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))
}
}
}
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
}
}
"internal/bytealg"
"internal/goarch"
"internal/runtime/math"
- "internal/runtime/strconv"
"internal/runtime/sys"
+ "internal/strconv"
"unsafe"
)
// 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
// 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
}
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)
import (
errpkg "errors"
- "internal/itoa"
+ "internal/strconv"
"runtime"
"unsafe"
)
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
}
// 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
// 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
}
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
}
package syscall
import (
- "internal/itoa"
+ "internal/strconv"
"runtime"
"sync"
"unsafe"
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])
import (
errorspkg "errors"
- "internal/itoa"
"internal/oserror"
+ "internal/strconv"
"sync"
"unsafe"
)
return s
}
}
- return "errno " + itoa.Itoa(int(e))
+ return "errno " + strconv.Itoa(int(e))
}
func (e Errno) Is(target error) bool {
return str
}
}
- return "signal " + itoa.Itoa(int(s))
+ return "signal " + strconv.Itoa(int(s))
}
var signals = [...]string{}
package syscall
import (
- "internal/itoa"
"internal/runtime/syscall/linux"
+ "internal/strconv"
"runtime"
"slices"
"unsafe"
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
errorspkg "errors"
"internal/asan"
"internal/bytealg"
- "internal/itoa"
"internal/msan"
"internal/oserror"
"internal/race"
+ "internal/strconv"
"runtime"
"sync"
"unsafe"
return s
}
}
- return "errno " + itoa.Itoa(int(e))
+ return "errno " + strconv.Itoa(int(e))
}
func (e Errno) Is(target error) bool {
return str
}
}
- return "signal " + itoa.Itoa(int(s))
+ return "signal " + strconv.Itoa(int(s))
}
func Read(fd int, p []byte) (n int, err error) {
import (
"errors"
- "internal/itoa"
"internal/oserror"
+ "internal/strconv"
"unsafe"
)
return s
}
}
- return "errno " + itoa.Itoa(int(e))
+ return "errno " + strconv.Itoa(int(e))
}
func (e Errno) Is(target error) bool {
case SIGSYS:
return "bad system call"
default:
- return "signal " + itoa.Itoa(int(s))
+ return "signal " + strconv.Itoa(int(s))
}
}
errorspkg "errors"
"internal/asan"
"internal/bytealg"
- "internal/itoa"
"internal/msan"
"internal/oserror"
"internal/race"
+ "internal/strconv"
"sync"
"unsafe"
)
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
return str
}
}
- return "signal " + itoa.Itoa(int(s))
+ return "signal " + strconv.Itoa(int(s))
}
func LoadCreateSymbolicLink() error {
package time
import (
- "internal/itoa"
+ "internal/strconv"
"syscall/js"
)
} 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}
}