cuelang.org/go@v0.13.0/internal/cueexperiment/exp.go (about) 1 package cueexperiment 2 3 import ( 4 "sync" 5 6 "cuelang.org/go/internal/envflag" 7 ) 8 9 // Flags holds the set of global CUE_EXPERIMENT flags. It is initialized by Init. 10 // 11 // When adding, deleting, or modifying entries below, 12 // update cmd/cue/cmd/help.go as well for `cue help environment`. 13 var Flags struct { 14 // EvalV3 enables the new evaluator. The new evaluator addresses various 15 // performance concerns. 16 EvalV3 bool `envflag:"default:true"` 17 18 // Embed enables file embedding. 19 // TODO(v0.14): deprecate this flag to forbid disabling this feature. 20 Embed bool `envflag:"default:true"` 21 22 // Enable topological sorting of struct fields. 23 // TODO(v0.14): deprecate this flag to forbid disabling this feature. 24 TopoSort bool `envflag:"default:true"` 25 26 // CmdReferencePkg requires referencing an imported tool package to declare tasks. 27 // Otherwise, declaring tasks by setting "$id" or "kind" string fields is allowed. 28 CmdReferencePkg bool 29 30 // The flags below describe completed experiments; they can still be set 31 // as long as the value aligns with the final behavior once the experiment finished. 32 // Breaking users who set such a flag seems unnecessary, 33 // and it simplifies using the same experiment flags across a range of CUE versions. 34 35 // Modules was an experiment which ran from early 2023 to late 2024. 36 Modules bool `envflag:"deprecated,default:true"` 37 38 // YAMLV3Decoder was an experiment which ran from early 2024 to late 2024. 39 YAMLV3Decoder bool `envflag:"deprecated,default:true"` 40 41 // DecodeInt64 was an experiment which ran from late 2024 to mid 2025. 42 DecodeInt64 bool `envflag:"deprecated,default:true"` 43 } 44 45 // Init initializes Flags. Note: this isn't named "init" because we 46 // don't always want it to be called (for example we don't want it to be 47 // called when running "cue help"), and also because we want the failure 48 // mode to be one of error not panic, which would be the only option if 49 // it was a top level init function. 50 func Init() error { 51 return initOnce() 52 } 53 54 var initOnce = sync.OnceValue(func() error { 55 return envflag.Init(&Flags, "CUE_EXPERIMENT") 56 })