Reputation: 61
I'm working on converting an existing Python library to Go and am getting hung up on a piece.
Is there a go equivalent to the following Python code?
test = "ec033aa702"
test.decode('hex')
I've been doing some reading but can't seem to find what I'm looking for.
Upvotes: 2
Views: 429
Reputation: 2575
Does this work for you?
package main
import (
"encoding/hex"
"fmt"
"log"
)
func main() {
const s = "ec033aa702"
decoded, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", decoded)
}
Upvotes: 1