Skip to content

runtime: add NoCopy documentation struct type? #8005

Closed
@bradfitz

Description

@bradfitz
From a conversation with Alan Donovan about how we might detect accidental copies of
types that shouldn't be copyable, I proposed:

package runtime  // or wherever

// NoCopy is an annotation that the containing type shouldn't be copied
// by value. It has zero size so may be embedded freely.
type NoCopy struct{}

Then we could do govet checks.

Or even compiler checks (more controversial probably).

Then sync.Cond and sync.Mutex could use it. The latter has no checks, because
sync.Cond's runtime copyChecker takes up space.

Only tagging this Go1.4 for eventual discussion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions