MCPcopy Index your code
hub / github.com/go-task/task / New

Function New

experiments/experiment.go:19–36  ·  view source on GitHub ↗

New creates a new experiment with the given name and sets the values that can enable it.

(xName string, config *ast.TaskRC, allowedValues ...int)

Source from the content-addressed store, hash-verified

17// New creates a new experiment with the given name and sets the values that can
18// enable it.
19func New(xName string, config *ast.TaskRC, allowedValues ...int) Experiment {
20 var value int
21 if config != nil {
22 value = config.Experiments[xName]
23 }
24
25 if value == 0 {
26 value, _ = strconv.Atoi(getEnv(xName))
27 }
28
29 x := Experiment{
30 Name: xName,
31 AllowedValues: allowedValues,
32 Value: value,
33 }
34 xList = append(xList, x)
35 return x
36}
37
38func (x Experiment) Enabled() bool {
39 return slices.Contains(x.AllowedValues, x.Value)

Callers 2

TestNewFunction · 0.92
ParseWithConfigFunction · 0.70

Calls 1

getEnvFunction · 0.85

Tested by 1

TestNewFunction · 0.74