cuelang.org/go@v0.10.1/internal/cuedebug/debug.go (about) 1 package cuedebug 2 3 import ( 4 "sync" 5 6 "cuelang.org/go/internal/envflag" 7 ) 8 9 // Flags holds the set of CUE_DEBUG flags. It is initialized by Init. 10 var Flags Config 11 12 type Config struct { 13 HTTP bool 14 15 // TODO: consider moving these evaluator-related options into a separate 16 // struct, so that it can be used in an API. We should use embedding, 17 // or some other mechanism, in that case to allow for the full set of 18 // allowed environment variables to be known. 19 20 // Strict sets whether extra aggressive checking should be done. 21 // This should typically default to true for pre-releases and default to 22 // false otherwise. 23 Strict bool 24 25 // LogEval sets the log level for the evaluator. 26 // There are currently only two levels: 27 // 28 // 0: no logging 29 // 1: logging 30 LogEval int 31 32 // Sharing enables structure sharing. 33 Sharing bool `envflag:"default:true"` 34 } 35 36 // Init initializes Flags. Note: this isn't named "init" because we 37 // don't always want it to be called (for example we don't want it to be 38 // called when running "cue help"), and also because we want the failure 39 // mode to be one of error not panic, which would be the only option if 40 // it was a top level init function. 41 func Init() error { 42 return initOnce() 43 } 44 45 var initOnce = sync.OnceValue(func() error { 46 return envflag.Init(&Flags, "CUE_DEBUG") 47 })