don't go ham on removing fmt useful data

This commit is contained in:
soypat
2026-09-04 06:27:05 -07:00
parent 88bd43bdd3
commit 3d15e0ff7b
6 changed files with 54 additions and 7 deletions
+12 -1
View File
@@ -1,6 +1,9 @@
package internal
import "strconv"
import (
"encoding/hex"
"strconv"
)
// AppendStrDecimal appends pfx followed by value in base 10 to dst and returns
// the resulting slice. It condenses the prefixed-number pattern common to
@@ -10,6 +13,14 @@ func AppendStrDecimal(dst []byte, pfx string, value int64) []byte {
return strconv.AppendInt(dst, value, 10)
}
// AppendStrHexData appends pfx followed by data as hexadecimaldata.
//
// dst = internal.AppendStrHexData(dst, "data=0x", data...) // data=0xdeadbeef
func AppendStrHexData(dst []byte, pfx string, data ...byte) []byte {
dst = append(dst, pfx...)
return hex.AppendEncode(dst, data)
}
// IntLen returns the number of bytes [strconv.AppendInt] emits for value in the
// given base, including a leading minus sign for negatives. Lets callers size a
// buffer, or test whether a value fits an existing slot, before writing a byte.