Skip to content

fmt,sync/atomic: fmt functions should allow integer verbs for atomic integers #54731

Open
@bcmills

Description

@bcmills

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.Int32is an atomic int32”, I expected that the fmt verbs that apply for int32 should generate the same representation when applied to an atomic.Int32.

Or, if the %d verb is not expected to work in the same way that it does for an int32, I expect the atomic package docs to note that detail.

What did you see instead?

Applying the %d verb to an atomic.Int32 prints it as a struct, not an integer:

{{} 42}

(CC @robpike @martisch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions