pragma

package
v0.0.0-alpha.14 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoNotCompare

type DoNotCompare [0]func()

DoNotCompare can be embedded in structs to prevent comparability.

References:

Example:

// Foo should not be compared.
type Foo struct {
  DoNotCompare
}
f1 := Foo{}
f2 := Foo{}
println(f1==f2) // Error. Comparing Foo is not allowed.

type DoNotCopy

type DoNotCopy [0]sync.Mutex

DoNotCopy can be embedded in structs to help prevent shallow copies. This does not rely on a Go language feature, but rather a special case within the vet checker.

References:

Example:

// Foo should not be shallow copied.
type Foo struct {
  DoNotCopy
}
f1 := Foo{}
f2 := f1 // Warning. Shallow copy is not allowed.

type DoNotImplement

type DoNotImplement interface{ DoNotCallMe(DoNotImplement) }

DoNotImplement can be embedded in interfaces to prevent trivial implementations of the interface. This is useful to prevent unauthorized implementations of an interface.

References:

Example:

// Hello interface cannot be implicitly implemented.
type Hello interface {
  DoNotImplement
  HelloWorld()
}

// Foo does not implement Hello interface.
type Foo struct {
}
func (f *Foo) HelloWorld() {}

// Bar does implement Hello interface.
type Bar struct {
  Hello
}
func (b *Bar) HelloWorld() {}

type NoUnkeyedLiterals

type NoUnkeyedLiterals struct{}

NoUnkeyedLiterals can be embedded in structs to prevent unkeyed literals.

References:

Example:

type Foo struct {
  NoUnkeyedLiterals
  name string
  age  int
}

f1 := Foo{"alice", 25} // NG. Unkeyed instantiation is not allowed.
f2 := Foo{name: "alice", age: 25} // OK.

Jump to

Keyboard shortcuts

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