mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-27 03:35:32 +00:00
internal/pragma: package to statically enforce certain properties
Package pragma provides certain constructs that can be used to statically enforce certain language properties. Change-Id: I58a87bf7429f3be1b5aae418595fadda32f9d039 Reviewed-on: https://go-review.googlesource.com/127822 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Herbie Ong <herbie@google.com>
This commit is contained in:
parent
7828bb327b
commit
ce91da5f05
29
internal/pragma/pragma.go
Normal file
29
internal/pragma/pragma.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
|
||||
// Package pragma provides types that can be embedded into a struct to
|
||||
// statically enforce or prevent certain language properties.
|
||||
package pragma
|
||||
|
||||
import "sync"
|
||||
|
||||
// NoUnkeyedLiterals can be embedded in a struct to prevent unkeyed literals.
|
||||
type NoUnkeyedLiterals struct{}
|
||||
|
||||
// DoNotImplement can be embedded in an interface to prevent trivial
|
||||
// implementations of the interface.
|
||||
//
|
||||
// This is useful to prevent unauthorized implementations of an interface
|
||||
// so that it can be extended in the future for any protobuf language changes.
|
||||
type DoNotImplement interface{ ProtoInternal(DoNotImplement) }
|
||||
|
||||
// DoNotCompare can be embedded in a struct to prevent comparability.
|
||||
type DoNotCompare [0]func()
|
||||
|
||||
// DoNotCopy can be embedded in a struct to help prevent shallow copies.
|
||||
// This does not rely on a Go language feature, but rather a special case
|
||||
// within the vet checker.
|
||||
//
|
||||
// See https://golang.org/issues/8005.
|
||||
type DoNotCopy [0]sync.Mutex
|
Loading…
x
Reference in New Issue
Block a user