S2B converts string to a byte slice without memory allocation. Note it may break if string and/or slice header will change in the future go versions.
(s string)
| 24 | // Note it may break if string and/or slice header will change |
| 25 | // in the future go versions. |
| 26 | func S2B(s string) (b []byte) { |
| 27 | return unsafe.Slice(unsafe.StringData(s), len(s)) |
| 28 | } |
| 29 | |
| 30 | func MustParseHexStr(s string) []byte { |
| 31 | result, err := hex.DecodeString(s) |
no outgoing calls
no test coverage detected