[]byte -> String (hexadecimal)
1 src := [] byte ( " Hello " ) 2 encodedStr := hex.EncodeToString(src) 3 // Note that "Hello" and "encodedStr" are not equal, encodedStr is a string to represent hexadecimal
String -> []byte
1 test, _ := hex.DecodeString(encodedStr) 2 fmt.Println(bytes.Compare(test, src)) // 0
原文:ttps://blog.csdn.net/jason_cuijiahui/article/details/79418557