MustParse is like Parse but panics if the string cannot be parsed. It simplifies safe initialization of global variables holding compiled UUIDs.
(s string)
| 192 | // MustParse is like Parse but panics if the string cannot be parsed. |
| 193 | // It simplifies safe initialization of global variables holding compiled UUIDs. |
| 194 | func MustParse(s string) UUID { |
| 195 | uuid, err := Parse(s) |
| 196 | if err != nil { |
| 197 | panic(`uuid: Parse(` + s + `): ` + err.Error()) |
| 198 | } |
| 199 | return uuid |
| 200 | } |
| 201 | |
| 202 | // FromBytes creates a new UUID from a byte slice. Returns an error if the slice |
| 203 | // does not have a length of 16. The bytes are copied from the slice. |