Closed jrefior closed 5 years ago
I can write a convenience function to check for the zero value. For example:
package main import ( "fmt" "github.com/google/uuid" ) func IsZero(id uuid.UUID) bool { for x := 0; x < 16; x++ { if id[x] != 0 { return false } } return true } func main() { id := uuid.UUID{} fmt.Printf("is %v zero? %t\n", id, IsZero(id)) id, _ = uuid.NewRandom() fmt.Printf("is %v zero? %t\n", id, IsZero(id)) }
Is that the thing to do, or is there a better way to check for the zero value?
yes, just test id == uuid.Nil
id == uuid.Nil
Ah thank you, I missed that in the Variables section of GoDoc.
I can write a convenience function to check for the zero value. For example:
Is that the thing to do, or is there a better way to check for the zero value?