I'm trying to parse a slice of bytes with the below value 020000
to as a base 16 number but haven't gotten it working yet. What am I doing wrong?
package main
import (
"fmt"
"strconv"
)
func main() {
input := []byte{0, 2, 0, 0, 0, 0}
expectation := 131072
actual := headerVersion(input)
if actual != expectation {
panic(fmt.Sprintf("Expected %v but got %v.", expectation, actual))
}
}
func headerVersion(input []byte) int {
output, _ := strconv.ParseUint(string(input), 16, 64)
return int(output)
}