Created
July 30, 2015 17:24
-
-
Save dt/e8fabc7157aeda475708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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