-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalv2An incompatible library changeAn incompatible library change
Milestone
Description
Most structs are actually not safe to copy. Most code handles structs by pointer because it is the best way to avoid accidentally copying it. (And there's hard-coding to prevent sync.Mutex being copied because of how often that mistake got made!)
Go 2 should accept this reality and make structs non-copyable by default. The copy() method could be extended to allow struct copying, and people who really want copyable structs can provide a method to call copy() for you.
Note that this doesn't stop moves of structs, e.g. returning them. Accepting them by value is a more complex question, since it introduces the possibility of an "empty" variable in many cases.
beoran, ericlagergren, dpinela, tmthrgd, shaxbee and 1 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalv2An incompatible library changeAn incompatible library change