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.
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
Drop go.uber.org/atomic in favor of sync/atomic #3443
Drop go.uber.org/atomic in favor of sync/atomic #3443
Changes from 1 commit
42d29e3
2515c42
1a41b94
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This seems like a really bad situation - I need to review my Golang a bit, but if this is non-nil, this means that the thing that was stored was not an error on
e.err
, which would be a system error in itself.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.
yeah, I think for safety purposes you could move
onceError
to a different package so someone within this package can't muck with thee.err
value directly (instead of usingStore
)?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.
Maybe, but that's not really what I'm saying - I'm saying that you are returning
nil
whenok == false
, andok
should only be false ife.err.Load()
is not of typeerror
, which would be a really bad scenario (somehow something other than anerror
got stored one.err
.ok might also be
falseif
e.err.Load()is
nil`, but this is where my Golang is failing me - I assume that's the only thing that is meant to be captured here.I would imagine that if you want to do something like this, you need to do:
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.
yeah, that looks more technically correct to me - if you somehow stored something that isn't type
error
, you'd always just getnil
currently. I'll update to your approach.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.
1a41b94 - feel free to change, just preferred the
atomicValue
var name.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.
lgtm - I would probably update bufstream as well
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.
took this from a bufstream PR; could use a raw
atomic.Value
inline, but this prevents needing to do the type assertion at the callsite. 🤷.