FromString returns a new ID from given hash by using the hasher or an error if it couldn't decode the hash.
(id string)
| 2 | |
| 3 | // FromString returns a new ID from given hash by using the hasher or an error if it couldn't decode the hash. |
| 4 | func FromString(id string) (ID, error) { |
| 5 | return hash.Decode([]byte(id)) |
| 6 | } |
| 7 | |
| 8 | // ToString returns a new hash from given ID by using the hasher or an error if it couldn't encode the ID. |
| 9 | // If ID is 0, "null" will be returned. |