Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pick ¶ added in v0.21.0
Pick returns a when cond is true and b otherwise.
It is the expression form of a two-branch if, for cases where the choice is a value rather than control flow:
check: util.Pick(agent.IsAgentMode(), check.AgentCheck, check.DefaultCheck),
Both arguments are evaluated before the call, so never use it where one operand is only valid under the condition - Pick(a.HasIndex(i), a[i], "") panics on the very case the guard exists for. Use PickF there, and also when either side is expensive or has side effects.
func PickF ¶ added in v0.21.0
PickF returns a() when cond is true and b() otherwise, evaluating only the branch it takes.
Use it where Pick would be unsafe or wasteful - when an operand is only valid under the condition, is expensive, or has side effects:
util.PickF(a.HasIndex(i), func() string { return a[i] }, func() string { return "" })
Types ¶
This section is empty.