all: use new AppendEncode methods available in Go 1.22 (#11079)

Updates #cleanup

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2024-02-08 17:55:03 -08:00
committed by GitHub
parent 94a4f701c2
commit 2e404b769d
4 changed files with 8 additions and 42 deletions
+1 -9
View File
@@ -53,18 +53,10 @@ func clamp25519Private(b []byte) {
func appendHexKey(dst []byte, prefix string, key []byte) []byte {
dst = slices.Grow(dst, len(prefix)+hex.EncodedLen(len(key)))
dst = append(dst, prefix...)
dst = hexAppendEncode(dst, key)
dst = hex.AppendEncode(dst, key)
return dst
}
// TODO(https://go.dev/issue/53693): Use hex.AppendEncode instead.
func hexAppendEncode(dst, src []byte) []byte {
n := hex.EncodedLen(len(src))
dst = slices.Grow(dst, n)
hex.Encode(dst[len(dst):][:n], src)
return dst[:len(dst)+n]
}
// parseHex decodes a key string of the form "<prefix><hex string>"
// into out. The prefix must match, and the decoded base64 must fit
// exactly into out.