Skip to content

Correct Way to Enforce Uniqueness on Insertion By Kind and Default States #704

Answered by brandur
themaxgoldman asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, it's intended behavior — checking a struct is zero valued versus not is generally a bit more conventional in Go compared to check a pointer.

ExcludeKind: false won't work because false is the zero value for a boolean so there's no way in Go to check whether you set a false value explicitly versus got a default zero value.

Honestly, we've never gotten this request before. Usually when you're checking for uniqueness you're trying to do it on some other dimension beyond just the job's kind like period. As things stand, you might have to use something like ByArgs: true (if your args are stable), or set the list of default unique states:

ByState: []rivertype.JobState{rivertype.JobStateAva…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bgentry
Comment options

@themaxgoldman
Comment options

@brandur
Comment options

Answer selected by themaxgoldman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants