github.com/tobgu/qframe@v0.4.0/types/aliases.go (about) 1 package types 2 3 /* 4 This slightly unconventional use of type aliasing is meant to provide a hook for documentation 5 of the different uses of interface{} that exists in QFrame. Since there is nothing like a union 6 or a sum type in Go, QFrame settles for the use of interface{} for some input. 7 8 Hopefully this construct says a bit more than nothing about the empty interfaces used. 9 */ 10 11 /* 12 DataSlice can be a slice of any of the supported data types. 13 14 The following types are currently supported: 15 []bool 16 []float64 17 []int 18 []string 19 []*string 20 */ 21 type DataSlice = interface{} 22 23 /* 24 SliceFuncOrBuiltInId can be a function taking a slice of type T and returning a value of type T. 25 26 For example: 27 func(x []float64) float64 28 func(x []int) int 29 func(x []*string) *string 30 func(x []bool) bool 31 32 Or it can be a string identifying a built in function. 33 34 For example: 35 "sum" 36 37 IMPORTANT: Reference arguments (eg. slices) must never be assumed to be valid after that the passed function returns. 38 Under the hood reuse and other performance enhancements may trigger unexpected behaviour if this is ever done. 39 If, for some reason, you want to retain the data a copy must be made. 40 */ 41 type SliceFuncOrBuiltInId = interface{} 42 43 /* 44 DataFuncOrBuiltInId can be a function taking one argument of type T and returning a value of type U. 45 46 For example: 47 func(x float64) float64 48 func(x float64) int 49 50 Or it can be a function taking zero arguments returning a value of type T. 51 52 For example: 53 func() float64 54 func() int 55 56 Or it can be a function taking two arguments of type T and returning a value of type T. Note that arguments 57 and return values must all have the same type in this case. 58 59 For example: 60 func(x, y float64) float64 61 func(x, y int) int 62 63 Or it can be a string identifying a built in function. 64 65 For example: 66 "abs" 67 68 IMPORTANT: Pointer arguments (eg. *string) must never be assumed to be valid after that the passed function returns. 69 Under the hood reuse and other performance enhancements may trigger unexpected behaviour if this is ever done. 70 If, for some reason, you want to retain the data a copy must be made. 71 */ 72 type DataFuncOrBuiltInId = interface{}