MarshalText satisfies the TextMarshaler interface. It returns the bytes of h encoded in hex, for formats that can't hold arbitrary binary data. It never returns an error.
()
| 44 | // for formats that can't hold arbitrary binary data. |
| 45 | // It never returns an error. |
| 46 | func (h Hash) MarshalText() ([]byte, error) { |
| 47 | b := h.Byte32() |
| 48 | v := make([]byte, 64) |
| 49 | hex.Encode(v, b[:]) |
| 50 | return v, nil |
| 51 | } |
| 52 | |
| 53 | // UnmarshalText satisfies the TextUnmarshaler interface. |
| 54 | // It decodes hex data from b into h. |