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 ¶
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:
- https://pkg.go.dev/google.golang.org/protobuf/internal/pragma#DoNotCopy
 - https://golang.org/issues/8005.
 
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.
  
     Click to show internal directories. 
   Click to hide internal directories.