xref: /aosp_15_r20/external/golang-protobuf/internal/pragma/pragma.go (revision 1c12ee1efe575feb122dbf939ff15148a3b3e8f2)
1*1c12ee1eSDan Willemsen// Copyright 2018 The Go Authors. All rights reserved.
2*1c12ee1eSDan Willemsen// Use of this source code is governed by a BSD-style
3*1c12ee1eSDan Willemsen// license that can be found in the LICENSE file.
4*1c12ee1eSDan Willemsen
5*1c12ee1eSDan Willemsen// Package pragma provides types that can be embedded into a struct to
6*1c12ee1eSDan Willemsen// statically enforce or prevent certain language properties.
7*1c12ee1eSDan Willemsenpackage pragma
8*1c12ee1eSDan Willemsen
9*1c12ee1eSDan Willemsenimport "sync"
10*1c12ee1eSDan Willemsen
11*1c12ee1eSDan Willemsen// NoUnkeyedLiterals can be embedded in a struct to prevent unkeyed literals.
12*1c12ee1eSDan Willemsentype NoUnkeyedLiterals struct{}
13*1c12ee1eSDan Willemsen
14*1c12ee1eSDan Willemsen// DoNotImplement can be embedded in an interface to prevent trivial
15*1c12ee1eSDan Willemsen// implementations of the interface.
16*1c12ee1eSDan Willemsen//
17*1c12ee1eSDan Willemsen// This is useful to prevent unauthorized implementations of an interface
18*1c12ee1eSDan Willemsen// so that it can be extended in the future for any protobuf language changes.
19*1c12ee1eSDan Willemsentype DoNotImplement interface{ ProtoInternal(DoNotImplement) }
20*1c12ee1eSDan Willemsen
21*1c12ee1eSDan Willemsen// DoNotCompare can be embedded in a struct to prevent comparability.
22*1c12ee1eSDan Willemsentype DoNotCompare [0]func()
23*1c12ee1eSDan Willemsen
24*1c12ee1eSDan Willemsen// DoNotCopy can be embedded in a struct to help prevent shallow copies.
25*1c12ee1eSDan Willemsen// This does not rely on a Go language feature, but rather a special case
26*1c12ee1eSDan Willemsen// within the vet checker.
27*1c12ee1eSDan Willemsen//
28*1c12ee1eSDan Willemsen// See https://golang.org/issues/8005.
29*1c12ee1eSDan Willemsentype DoNotCopy [0]sync.Mutex
30