package str import "encoding/hex" // struing to hex func (s *Str) HexEncode(str string) string { byteStr := []byte(str) return hex.EncodeToString(byteStr) } // hex to string func (s *Str) HexDecode(str string) (string, error) { hexStr, err := hex.DecodeString(str) if err != nil { panic(err) return "", err } return string(hexStr), nil }