Debian Codegraph @

errors/itoa.go

raw symbols SCIP
1 package errors
2
3 // itoa converts val to a decimal string. It allows this package to
4 // avoid a dependency on strconv. Adapted from net/parse.go
5 func appendInt(buf []byte, val int) []byte {
6 if val < 0 {
7 buf = append(buf, '-')
8 return appendUint(buf, uint(-val))
9 }
10 return appendUint(buf, uint(val))
11 }
12
13 func appendUint(p []byte, val uint) []byte {
14 var buf [20]byte // big enough for 64bit value base 10
15 i := len(buf) - 1
16 for val >= 10 {
17 q := val / 10
18 buf[i] = byte('0' + val - q*10)
19 i--
20 val = q
21 }
22 // val < 10
23 buf[i] = byte('0' + val)
24 return append(p, buf[i:]...)
25 }