Skip to content

time: is documented as safe for concurrent use, but unmarshal methods do not synchronize #19935

@nicholasmaniscalco

Description

@nicholasmaniscalco

time.Time is documented as being safe for concurrent use, however, some methods modify it without synchronization: GobDecode, UnmarshalBinary, UnmarshalJSON, and UnmarshalText.

It seems like we should update the documentation. What's the right way to document the goroutine-safety guarantee? Something like:

"A Time value can be used by multiple goroutines simultaneously so long as no goroutine calls an unmarshaler method (t.GobDecode, t.UnmarshalBinary, t.UnmarshalJSON, t.UnmarshalText)." ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions