-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
fmt,sync/atomic: fmt
functions should allow integer verbs for atomic integers
#54731
Comments
…egers * treat `atomic.{Int32,Int64,Uint32,Uint64}` values as integers when formatting, using the underlying integer value (by calling Load). This has the effect of, for example, formatting an atomic integer type containing 42 as "42", not "{{}, 42}"). * treat `atomic.Bool` values as booleans when formatting, using the contained boolean value (by calling Load). This has the effect of, for example, formatting an true atomic.Bool value containing as "true", not "{{}, 1}" or "{{} %!t(uint32=1)}" as before. Fixes golang#54731
…egers * treat `atomic.{Int32,Int64,Uint32,Uint64}` values as integers when formatting, using the underlying integer value (by calling Load). This has the effect of, for example, formatting an atomic integer type containing 42 as "42", not "{{}, 42}"). * treat `atomic.Bool` values as booleans when formatting, using the contained boolean value (by calling Load). This has the effect of, for example, formatting an true atomic.Bool value containing as "true", not "{{}, 1}" or "{{} %!t(uint32=1)}" as before. Fixes golang#54731
Change https://go.dev/cl/426456 mentions this issue: |
I think that passing an Also, I'm not certain that the documentation already allows the If we want to support |
Interesting — the |
That's odd, I feel like it was at some point because I've definitely had the |
Slightly related to #54582 I think. |
What version of Go are you using (
go version
)?go 1.19
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?https://go.dev/play/p/jHX7pcphAmV
What did you do?
Format an
atomic.Int32
using the%d
verb.What did you expect to see?
Since an
atomic.Int32
“is an atomicint32
”, I expected that thefmt
verbs that apply forint32
should generate the same representation when applied to anatomic.Int32
.Or, if the
%d
verb is not expected to work in the same way that it does for anint32
, I expect theatomic
package docs to note that detail.What did you see instead?
Applying the
%d
verb to anatomic.Int32
prints it as a struct, not an integer:(CC @robpike @martisch)
The text was updated successfully, but these errors were encountered: