blob: daf2817091d0ae6c9246c3bef95cd9e8208fbfe8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// SPDX-FileCopyrightText: © 2022 Grégoire Duchêne <gduchene@awhk.org>
// SPDX-License-Identifier: ISC
package core
// Must panics if err is not nil. It returns val otherwise.
func Must[T any](val T, err error) T {
if err != nil {
panic(err)
}
return val
}
// NoCopy flags a type that embeds it as not to be copied. Go does not
// prevent values from being copied, but ‘go vet’ will pick it up and
// signal it, which can then be caught by many CI/CD pipelines.
//
// See https://github.com/golang/go/issues/8005#issuecomment-190753527
// for more details.
type NoCopy struct{}
func (*NoCopy) Lock() {}
func (*NoCopy) Unlock() {}
|