Running the following little program to decode a string:
package main
import (
"fmt"
"encoding/hex"
)
func main()
{
var answer []byte
b, e := hex.Decode(answer, []byte("98eh1298e1h182he"))
fmt.Println(b)
fmt.Println(e)
}
Results in panic: runtime error: index out of range
, though that is not a very helpful error message. What am I doing wrong?
The same is true for encoding:
package main
import (
"fmt"
"encoding/hex"
)
func main()
{
var answer []byte
e := hex.Encode(answer, []byte("98eh1298e1h182he"))
fmt.Println(answer)
fmt.Println(e)
}