1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| package util
const ( BoolTrue = "true" BoolFalse = "false" )
func Choose[T any](b bool, ifTrue T, ifFalse T) T { if b { return ifTrue } return ifFalse }
func OrDefault[T comparable](x T, dflt T) T { var chk T return Choose(chk == x, dflt, x) }
|