nocopy

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Nocopy

Types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures.

Types

  • NoCopy - Embed in structs to prevent copying (detected by go vet)
  • CopyChecker - Runtime copy detection that panics if the struct has been copied

Use these types in cryptographic and security-sensitive code where copying could lead to bugs or security issues.

Documentation

Overview

Package nocopy provides types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures.

See README.md for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyChecker

type CopyChecker uintptr

CopyChecker holds back pointer to itself to detect object copying.

func (*CopyChecker) Check

func (c *CopyChecker) Check()

Check panics if the object has been copied since the last call to Check.

type NoCopy

type NoCopy struct{}

NoCopy may be added to structs which must not be copied after the first use.

See https://golang.org/issues/8005#issuecomment-190753527 for details.

Note that it must not be embedded, due to the Lock and Unlock methods.

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock is a no-op used by -copylocks checker from `go vet`.

func (*NoCopy) Unlock

func (*NoCopy) Unlock()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL