-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
fix KVOp types #2531
Merged
Merged
fix KVOp types #2531
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to repeat the
KVOp
here, the first one will set them all. It was the change to the struct below that fixed this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik that only works for
iota
assignments. This is the output of gist https://gist.github.com/alicebob/aa17022b6f1d6f8fbf3337e2c178c858There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relevant piece from the Go language specs:
https://golang.org/ref/spec#Constant_declarations
Since the expression isn't empty (it's a string) you need to repeat the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alicebob that clause in the spec is to allow for
iota
, basically. The section before that talks about the type being optional, not the expression part. I tried it in the Go playground and it worked fine with just the one type, and we do that in lots of other places in Consul :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Morning @slackpad. Sorry to make such a fuzz about a few lines, but it's not the same thing. The types don't get copied over; it happens to work because the definitions without a type are untyped string constants. Not specifying a type at all also works fine:
If you only add a KVOp type for
KVSet
thenKVSet
will be a typed string, butKVDelete
will still be untyped. So I would either add the type on every line, or not at all.Have a look at my Gist posted above, and reread the 'String constants' part from https://blog.golang.org/constants .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh thanks for the correction and sorry I missed the gist output above - my understanding was definitely incorrect!