Documentation
¶
Index ¶
- func C0(err error)
- func C1[T1 comparable](v1 T1, err error) T1
- func C2[T1, T2 comparable](v1 T1, v2 T2, err error) (T1, T2)
- func Contains[T comparable](a []T, v T)
- func Diff[V comparable](a, b V)
- func Different[V comparable](a, b V)
- func Done(err error)
- func Equals[V comparable](a, b V)
- func FALSE(v bool)
- func False(v bool)
- func Full[T any](v *T) *T
- func Have[T any](a []T) []T
- func In[T comparable](v T, a []T)
- func Is[V comparable](a, b V)
- func Ise(err, target error)
- func Len[T any](a []T, n int)
- func Length[T any](a []T, n int)
- func Must(err error)
- func Nice[V comparable](a V) V
- func None[V comparable](a V)
- func Null[T any](v *T)
- func OK[V comparable](a V)
- func Ok[V comparable](a V)
- func P0(err error)
- func P1[T1 any](v1 *T1, err error) *T1
- func P2[T1, T2 any](v1 *T1, v2 *T2, err error) (*T1, *T2)
- func Same[V comparable](a, b V)
- func SameNice[V comparable](a, b V) V
- func Sane[V comparable](a, b V) V
- func TRUE(v bool)
- func True(v bool)
- func V0(err error)
- func V1[T1 any](v1 T1, err error) T1
- func V2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)
- func Zero[V comparable](a V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func C1 ¶
func C1[T1 comparable](v1 T1, err error) T1
func C2 ¶
func C2[T1, T2 comparable](v1 T1, v2 T2, err error) (T1, T2)
func Contains ¶
func Contains[T comparable](a []T, v T)
Contains checks if the slice contains the value. Panics if the value is not found. Contains 检查切片是否包含该值。如果未找到该值,则触发 panic。
func Diff ¶ added in v0.0.17
func Diff[V comparable](a, b V)
func Different ¶ added in v0.0.16
func Different[V comparable](a, b V)
func Done ¶
func Done(err error)
Done expects no error. Panics if the provided error is non-nil. Done 期望没有错误。如果提供的错误不为 nil,则触发 panic。
func Equals ¶
func Equals[V comparable](a, b V)
Equals expects the values to be equal. Panics if they are not equal. Equals 期望值相等。如果值不相等,则触发 panic。
func FALSE ¶
func FALSE(v bool)
FALSE expects the value to be false. Panics if the value is true. FALSE 期望值为 false。如果值为 true,则触发 panic。
func False ¶
func False(v bool)
False expects the value to be false. Panics if the value is true. False 期望值为 false。如果值为 true,则触发 panic。
func Full ¶
func Full[T any](v *T) *T
Full expects the value to be non-nil. Panics if the value is nil. Full 期望值为非 nil。如果值为 nil,则触发 panic。
func Have ¶
func Have[T any](a []T) []T
Have checks that the slice is not empty/none. Panics if the slice is empty/none. Have 检查切片是否为空。如果切片为空,则触发 panic。
func In ¶
func In[T comparable](v T, a []T)
In checks if the value is in the slice. Panics if the value is not found. In 检查值是否在切片中。如果未找到该值,则触发 panic。
func Is ¶
func Is[V comparable](a, b V)
Is expects equality, not the logic of errors.Is, but the logic of Equals. Panics if the values are not equal. Is 期望相等,不是 errors.Is 的逻辑,而是 Equals 的逻辑。如果值不相等,则触发 panic。
func Ise ¶
func Ise(err, target error)
Ise expects the errors to be equal, similar to the behavior of errors.Is. Panics if they are not equal. Ise 期望错误相等,类似于 errors.Is 的行为。如果错误不相等,则触发 panic。
func Len ¶
Len is an abbreviation of Length, serving the same purpose. Panics if the length is not n. Len 是 Length 的缩写,功能相同。如果长度不是 n,则触发 panic。
func Length ¶
Length expects the slice to have length n. Panics if the length is not n. Length 期望切片的长度为 n。如果长度不是 n,则触发 panic。
func Must ¶
func Must(err error)
Must expects no error. Panics if the provided error is non-nil. Must 期望没有错误。如果提供的错误不为 nil,则触发 panic。
func Nice ¶
func Nice[V comparable](a V) V
Nice expects a non-zero value. Panics if the value is zero, returns the value if non-zero. Nice 期望一个非零值。如果值为零,则触发 panic;如果值非零,则返回该值。
func None ¶
func None[V comparable](a V)
None expects a zero value (empty/none). Panics if the value is non-zero. None 期望值为零(空)。如果值不为零,则触发 panic。
func Null ¶
func Null[T any](v *T)
Null expects the value to be nil. Panics if the value is non-nil. Null 期望值为 nil。如果值不为 nil,则触发 panic。
func OK ¶
func OK[V comparable](a V)
OK expects a non-zero value. Panics if the value is zero. Provides an alternative name for preference. OK 期望一个非零值。如果值为零,则触发 panic。提供一个偏好的替代名称。
func Ok ¶
func Ok[V comparable](a V)
Ok expects a non-zero value. Panics if the value is zero. Ok 期望一个非零值。如果值为零,则触发 panic。
func Same ¶
func Same[V comparable](a, b V)
Same expects the values to be same. Panics if they are not same. Same 期望值相等。如果值不相等,则触发 panic。
func SameNice ¶ added in v0.0.18
func SameNice[V comparable](a, b V) V
SameNice expects the values to be the same and non-zero. Panics if they are not the same or if the value is zero. Returns the value if the conditions are met. SameNice 期望值相等且非零。如果值不相等或为零,则触发 panic。如果条件满足,则返回该值。
func Sane ¶ added in v0.0.19
func Sane[V comparable](a, b V) V
Sane means same && nice Sane 期望值相等且非零。如果值不相等或为零,则触发 panic。如果条件满足,则返回该值。
func TRUE ¶
func TRUE(v bool)
TRUE expects the value to be true. Panics if the value is false. TRUE 期望值为 true。如果值为 false,则触发 panic。
func True ¶
func True(v bool)
True expects the value to be true. Panics if the value is false. True 期望值为 true。如果值为 false,则触发 panic。
func Zero ¶
func Zero[V comparable](a V)
Zero expects a zero value. Panics if the value is non-zero. Zero 期望值为零。如果值不为零,则触发 panic。
Types ¶
This section is empty.