cuelang.org/go@v0.10.1/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 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  	Modules bool `envflag:"default:true"`
    15  
    16  	// YAMLV3Decoder swaps the old internal/third_party/yaml decoder with the new
    17  	// decoder implemented in internal/encoding/yaml on top of yaml.v3.
    18  	YAMLV3Decoder bool `envflag:"default:true"`
    19  
    20  	// EvalV3 enables the new evaluator. The new evaluator addresses various
    21  	// performance concerns.
    22  	EvalV3 bool
    23  
    24  	// Embed enabled file embedding.
    25  	Embed bool
    26  }
    27  
    28  // Init initializes Flags. Note: this isn't named "init" because we
    29  // don't always want it to be called (for example we don't want it to be
    30  // called when running "cue help"), and also because we want the failure
    31  // mode to be one of error not panic, which would be the only option if
    32  // it was a top level init function.
    33  func Init() error {
    34  	return initOnce()
    35  }
    36  
    37  var initOnce = sync.OnceValue(initAlways)
    38  
    39  func initAlways() error {
    40  	return envflag.Init(&Flags, "CUE_EXPERIMENT")
    41  }