package cueexperiment
import "cuelang.org/go/internal/cueexperiment"
Index ¶
- func CanApplyFix(experiment, version, target string) error
- func GetActive(origVersion, targetVersion string) []string
- func GetUpgradable(origVersion, targetVersion string) []string
- func Init() error
- func IsPreview(experiment, version string) bool
- func IsStable(experiment, version string) bool
- func ShouldRemoveAttribute(experiment, version string) bool
- type Config
- type File
Functions ¶
func CanApplyFix ¶
CanApplyFix validates whether an experiment fix can be applied to a file with the given version and existing experiments.
func GetActive ¶
GetActive returns all experiments that are active (can be enabled) for the given version, but not yet accepted.
func GetUpgradable ¶
GetUpgradable returns all experiments that are stable (possibly in later versions), that can be upgraded from the current version (must be lower than stable) to the desired version.
func Init ¶
func Init() error
Init initializes Flags. Note: this isn't named "init" because we don't always want it to be called (for example we don't want it to be called when running "cue help"), and also because we want the failure mode to be one of error not panic, which would be the only option if it was a top level init function.
func IsPreview ¶
IsPreview returns true if the experiment exists and can be used for the given version.
func IsStable ¶
IsStable returns true if the experiment is stable (no longer experimental) for the given version.
func ShouldRemoveAttribute ¶
ShouldRemoveAttribute returns true if the experiment attribute should be removed because the experiment is stable for the given version.
Types ¶
type Config ¶
type Config struct {
// CmdReferencePkg requires referencing an imported tool package to declare tasks.
// Otherwise, declaring tasks via "$id" or "kind" string fields is allowed.
CmdReferencePkg bool `experiment:"preview:v0.13.0,default:v0.14.0"`
// KeepValidators prevents validators from simplifying into concrete values,
// even if their concrete value could be derived, such as '>=1 & <=1' to '1'.
// Proposal: https://cuelang.org/discussion/3775.
// Spec change: https://cuelang.org/cl/1217013
// Spec change: https://cuelang.org/cl/1217014
KeepValidators bool `experiment:"preview:v0.14.0,default:v0.14.0,stable:v0.15.0"`
// Modules enables support for the modules and package management proposal
// as described in https://cuelang.org/discussion/2939.
Modules bool `experiment:"preview:v0.8.0,default:v0.9.0,stable:v0.11.0"`
// YAMLV3Decoder swaps the old internal/third_party/yaml decoder with the new
// decoder implemented in internal/encoding/yaml on top of yaml.v3.
YAMLV3Decoder bool `experiment:"preview:v0.9.0,default:v0.9.0,stable:v0.11.0"`
// DecodeInt64 changes [cuelang.org/go/cue.Value.Decode] to choose
// 'int64' rather than 'int' as the default type for CUE integer values
// to ensure consistency with 32-bit platforms.
DecodeInt64 bool `experiment:"preview:v0.11.0,default:v0.12.0,stable:v0.13.0"`
// Embed enables support for embedded data files as described in
// https://cuelang.org/discussion/3264.
Embed bool `experiment:"preview:v0.10.0,default:v0.12.0,stable:v0.14.0"`
// TopoSort enables topological sorting of struct fields.
// Provide feedback via https://cuelang.org/issue/3558.
TopoSort bool `experiment:"preview:v0.11.0,default:v0.12.0,stable:v0.14.0"`
// EvalV3 enables the new CUE evaluator, addressing performance issues
// and bringing better algorithms for disjunctions, closedness, and cycles.
EvalV3 bool `experiment:"preview:v0.9.0,default:v0.13.0,stable:v0.15.0"`
}
Config holds the set of known CUE_EXPERIMENT flags.
When adding, deleting, or modifying entries below, update cmd/cue/cmd/help.go as well for `cue help environment`.
var Flags Config
Flags holds the set of global CUE_EXPERIMENT flags. It is initialized by Init.
type File ¶
type File struct {
// Testing is used to enable experiments for testing.
//
// TODO: we could later use it for enabling testing features, such as
// testing-specific builtins.
Testing bool `experiment:"preview:v0.13.0"`
// Accepted_ is for testing purposes only. It should be removed when an
// experiment is accepted and can be used to test this feature instead.
Accepted_ bool `experiment:"preview:v0.13.0,stable:v0.15.0"`
// StructCmp enables comparison of structs. This also defines the ==
// operator to be defined on all values. For instance, comparing 1 and
// "foo" will return false, whereas previously it would return an error.
//
// Proposal: https://cuelang.org/issue/2583
// Spec change: https://cuelang.org/cl/1217013
// Spec change: https://cuelang.org/cl/1217014
StructCmp bool `experiment:"preview:v0.14.0,stable:v0.15.0"`
// ExplicitOpen enables the postfix ... operator to explicitly open
// closed structs, allowing additional fields to be added.
//
// Proposal: https://cuelang.org/issue/4032
// Spec change: https://cuelang.org/cl/1221642
// Requires cue fix when upgrading
ExplicitOpen bool `experiment:"preview:v0.15.0"`
// AliasV2 enables the use of 'self' identifier to refer to the
// enclosing struct and enables the postfix alias syntax (~X and ~(K,V)).
// The file where this experiment is enabled disallows the use of old prefix
// alias syntax (X=).
//
// Proposal: https://cuelang.org/issue/4014
// Spec change: https://cuelang.org/cl/1222377
// Requires cue fix when upgrading
AliasV2 bool `experiment:"preview:v0.15.0"`
// contains filtered or unexported fields
}
File defines the experiments that can be set per file. Users can activate experiments by setting them using a file-based attribute @experiment() in a CUE file. When an experiment is first introduced, it is disabled by default.
preview: the version from when the experiment was introduced. stable: the version from when it is permanently set to true. withdrawn: results in an error if the user attempts to use the flag.
func NewFile ¶
NewFile parses the given comma-separated list of experiments for the given version and returns a PerFile struct with the experiments enabled. A empty version indicates the default version.
func (*File) LanguageVersion ¶
LanguageVersion returns the language version of the file or "" if no language version is associated with it.
Source Files ¶
exp.go file.go parse.go
- Version
- v0.15.1 (latest)
- Published
- Nov 21, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 4 months ago –
Tools for package owners.