Documentation ¶
Overview ¶
Package base 基础函数.
Index ¶
- Constants
- func If[T any](condition bool, trueVal, falseVal T) T
- func Must(err error)
- func Must1[T any](t T, err error) T
- func Must2[T1, T2 any](t1 T1, t2 T2, err error) (T1, T2)
- func Must3[T1, T2, T3 any](t1 T1, t2 T2, t3 T3, err error) (T1, T2, T3)
- func Param1[R any](r R, _ ...any) R
- func Param2[R any](_ any, r R, _ ...any) R
- func Param3[R any](_, _ any, r R, _ ...any) R
Examples ¶
Constants ¶
View Source
const ( Three = 3 Five = 5 Six = 6 Seven = 7 Nine = 9 Ten = 10 Hundred = 100 Million = 1e6 HundredMillion = 1e8 Billion = 1e9 )
View Source
const ( One = 1 << iota Two Four Eight Sixteen ThirtyTwo SixtyFour OneHundredTwentyEight TwoHundredFiftySix FiveHundredTwelve Kilo )
Variables ¶
This section is empty.
Functions ¶
func If ¶
If 三元表达式.
Example ¶
package main import ( "fmt" "github.com/xuender/kit/base" ) func main() { fmt.Println(base.If(true, 1, 2)) fmt.Println(base.If(false, 1, 2)) }
Output: 1 2
func Must1 ¶
Must1 1个返回值,error 必须是nil.
Example ¶
package main import ( "fmt" "github.com/xuender/kit/base" ) func main() { fmt.Println(base.Must1(1, nil)) }
Output: 1
func Must2 ¶
Must2 2个返回值, error 必须是nil.
Example ¶
package main import ( "fmt" "github.com/xuender/kit/base" ) func main() { fmt.Println(base.Must2(1, 2, nil)) }
Output: 1 2
func Must3 ¶
Must3 3个返回值, error 必须是nil.
Example ¶
package main import ( "fmt" "github.com/xuender/kit/base" ) func main() { fmt.Println(base.Must3(1, 2, 3, nil)) }
Output: 1 2 3
func Param1 ¶
Param1 返回第1个参数.
Example ¶
package main import ( "fmt" "github.com/xuender/kit/base" ) func main() { fmt.Println(base.Param1(1, 2, 3, 4)) }
Output: 1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.