Debian Codegraph @

gox/gox.go

raw symbols SCIP
1 // This file contains general utilities that do not warrant their own file.
2
3 package gox
4
5 // Pie is a "panic-if-error" utility: panics if the passed error is not nil.
6 // Should not be over-used, but may come handy to write code quickly.
7 func Pie(err error) {
8 if err != nil {
9 panic(err)
10 }
11 }
12
13 // Wrap returns its arguments as a slice.
14 //
15 // General use of Wrap is to wrap function calls, so the return values of the
16 // "wrapped" function will be available as a slice. Which then can be passed
17 // to variadic functions that have other parameters too.
18 //
19 // Most notable example is fmt.Printf(). This code doesn't compile:
20 // // Compile-time error!
21 // fmt.Printf("Year: %d, month: %d, day: %d", time.Now().Date())
22 //
23 // But with the help of this Wrap:
24 // // This is OK!
25 // fmt.Printf("Year: %d, month: %d, day: %d",
26 // Wrap(time.Now().Date())...)
27 //
28 // For details, see https://stackoverflow.com/a/52654950/1705598
29 func Wrap(vs ...interface{}) []interface{} {
30 return vs
31 }