Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider adding IsZero() property #92

Closed
kevinburke1 opened this issue May 24, 2021 · 3 comments
Closed

consider adding IsZero() property #92

kevinburke1 opened this issue May 24, 2021 · 3 comments

Comments

@kevinburke1
Copy link

Right now to tell if a UUID is entirely empty, you need to do this fairly clunky operation:

if bytes.Equal(myUUID[:], uuid.Nil[:]) {
    ...
}

It might be nice to add IsZero() - matching the API for time.Time - that will handle this for you.

@theckman
Copy link
Member

theckman commented May 24, 2021

@kevinburkemeter since they are an array type you can just compare them with ==. Any reason you can't do that here?

@izolate
Copy link

izolate commented Sep 20, 2021

@theckman You can't always count on having access to the uuid package, for example within Go templates, it would be nice to do this:

{{if .SomeUUID.IsZero}}
Some UUID is nil
{{end}}

+1 for the suggestion to add an IsZero method.

@cameracker
Copy link
Collaborator

Thanks for the recommendation @kevinburke1 , this has been contributed by @jordan-chalupka in #95, and is out for release in v4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants