.Thank you Peter & Bryan for your help, it's very instructive. I realized a Bench with all your solutions: https://play.golang.org/p/ePKkHNqTot
BenchmarkCharToInt32_0 : my original solution BenchmarkCharToInt32_1 : Bryan "code golf" solution. https://play.golang.org/p/Jxkf2Vheml BenchmarkHexToUint32_1 : Peter general HexToUint function. https://play.golang.org/p/OeUDEV9Xpb BenchmarkHexToUint32_2 : Peter Truncating the string to an even number solution https://play.golang.org/p/avf6xqnpEn BenchmarkHexToUint32_3 : Peter pad imput solution https://play.golang.org/p/Q6C9SBhQB5 BenchmarkHexToUint32_1-4 1000000 1280 ns/op 16 B/op 2 allocs/op --- FAIL: BenchmarkHexToUint32_2 HexToUint32_test.go:151: LittleEndian BenchmarkHexToUint32_2 failure [d682f983 cacac100] != [d682f983 cacac100 607a] --- FAIL: BenchmarkHexToUint32_3 HexToUint32_test.go:170: LittleEndian BenchmarkHexToUint32_3 failure [d682f983 cacac100] != [d682f983 cacac100 607a] BenchmarkCharToInt32_0-4 500000 2250 ns/op 96 B/op 22 allocs/op --- FAIL: BenchmarkCharToInt32_1 HexToUint32_test.go:208: encoding/hex: odd length hex string HexToUint32_test.go:212: LittleEndian BenchmarkHexToUint32_3 failure [d682f983 cacac100] != [] *Result :* - OK for BenchmarkHexToUint32_1 - KO for BenchmarkHexToUint32_2 & BenchmarkHexToUint32_3 - Error for BenchmarkCharToInt32_1 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.