DecodeString in Go

Posted by GoDoc
Public (Editable by Users)

DecodeString returns the bytes represented by the hexadecimal string s.

Go
Edit
package main

import (
	"encoding/hex"
	"fmt"
	"log"
)

func main() {
	const s = "48656c6c6f20476f7068657221"
	decoded, err := hex.DecodeString(s)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%s\n", decoded)
}