Skip to content

Instantly share code, notes, and snippets.

@dt
Created July 30, 2015 17:24
Show Gist options
  • Save dt/e8fabc7157aeda475708 to your computer and use it in GitHub Desktop.
Save dt/e8fabc7157aeda475708 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/hex"
"fmt"
)
func main() {
data := []byte("ab")
encoded := make([]byte, len(data)*2+1)
hex.Encode(encoded, data)
out := append(encoded, '\n')
fmt.Println("out len:\t", len(out))
fmt.Println("out hex:\t", out)
}
$ go run demo.go
out len: 6
out hex: [54 49 54 50 0 10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment