gocuelang.org/go/internal Index | Files | Directories

package internal

import "cuelang.org/go/internal"

Package internal exposes some cue internals to other packages.

A better name for this package would be technicaldebt.

Index

Variables

var BaseContext = Context{*apd.BaseContext.WithPrecision(34)}

BaseContext is used as CUE's default context for arbitrary-precision decimals.

Functions

func FileComments

func FileComments(f *ast.File) (docs, rest []*ast.CommentGroup)

func GenPath

func GenPath(root string) string

GenPath reports the directory in which to store generated files.

func IsDef

func IsDef(s string) bool

func IsDefOrHidden

func IsDefOrHidden(s string) bool

func IsDefinition

func IsDefinition(label ast.Label) bool

func IsHidden

func IsHidden(s string) bool

func IsRegularField

func IsRegularField(f *ast.Field) bool

func NewComment

func NewComment(isDoc bool, s string) *ast.CommentGroup

NewComment creates a new CommentGroup from the given text. Each line is prefixed with "//" and the last newline is removed. Useful for ASTs generated by code other than the CUE parser.

func Package

func Package(f *ast.File) (*ast.Package, int)

Package finds the package declaration from the preamble of a file, returning it, and its index within the file's Decls.

func SetConstraint

func SetConstraint(f *ast.Field, t token.Token)

SetConstraints sets both the main and deprecated fields of f according to the given constraint token.

func ToExpr

func ToExpr(n ast.Node) ast.Expr

ToExpr converts a node to an expression. If it is a file, it will return it as a struct. If is an expression, it will return it as is. Otherwise it panics.

func ToFile

func ToFile(n ast.Node) *ast.File

ToFile converts an expression to a file.

Adjusts the spacing of x when needed.

Types

type Attr

type Attr struct {
	Name   string // e.g. "json" or "protobuf"
	Body   string
	Kind   AttrKind
	Fields []KeyValue
	Err    errors.Error
	Pos    token.Pos
}

Attr holds positional information for a single Attr.

func NewNonExisting

func NewNonExisting(key string) Attr

NewNonExisting creates a non-existing attribute.

func ParseAttrBody

func ParseAttrBody(pos token.Pos, s string) (a Attr)

func (*Attr) Flag

func (a *Attr) Flag(pos int, key string) (bool, error)

Flag reports whether an entry with the given name exists at position pos or onwards or an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) Int

func (a *Attr) Int(pos int) (int64, error)

Int reports the integer at the given position or an error if the attribute is invalid, the position does not exist, or the value at the given position is not an integer.

func (*Attr) Lookup

func (a *Attr) Lookup(pos int, key string) (val string, found bool, err error)

Lookup searches for an entry of the form key=value from position pos onwards and reports the value if found. It reports an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) String

func (a *Attr) String(pos int) (string, error)

String reports the possibly empty string value at the given position or an error the attribute is invalid or if the position does not exist.

type AttrKind

type AttrKind uint8

AttrKind indicates the location of an attribute within CUE source.

const (
	// FieldAttr indicates an attribute is a field attribute.
	// foo: bar @attr()
	FieldAttr AttrKind = 1 << iota

	// DeclAttr indicates an attribute was specified at a declaration position.
	// foo: {
	//     @attr()
	// }
	DeclAttr
)

type Context

type Context struct {
	apd.Context
}

Context wraps apd.Context for CUE's custom logic.

Note that it avoids pointers to make it easier to make copies.

func (Context) Quo

func (c Context) Quo(d, x, y *apd.Decimal) (apd.Condition, error)

func (Context) Sqrt

func (c Context) Sqrt(d, x *apd.Decimal) (apd.Condition, error)

func (Context) WithPrecision

func (c Context) WithPrecision(p uint32) Context

WithPrecision mirrors upstream, but returning our type without a pointer.

type Decimal

type Decimal = apd.Decimal

A Decimal is an arbitrary-precision binary-coded decimal number.

Right now Decimal is aliased to apd.Decimal. This may change in the future.

type EvaluatorVersion

type EvaluatorVersion int

EvaluatorVersion is declared here so it can be used everywhere without import cycles, but the canonical documentation lives at cuelang.org/go/cue/cuecontext.EvalVersion.

TODO(mvdan): rename to EvalVersion for consistency with cuecontext.

const (
	// EvalVersionUnset is the zero value, which signals that no evaluator version is provided.
	EvalVersionUnset EvaluatorVersion = 0

	// DefaultVersion is a special value as it selects a version depending on the current
	// value of CUE_EXPERIMENT. It exists separately to [EvalVersionUnset], even though both
	// implement the same version selection logic, so that we can distinguish between
	// a user explicitly asking for the default version versus an entirely unset version.
	DefaultVersion EvaluatorVersion = -1 // TODO(mvdan): rename to EvalDefault for consistency with cuecontext

	EvalV2 EvaluatorVersion = 2
	EvalV3 EvaluatorVersion = 3

	StableVersion = EvalV3 // TODO(mvdan): rename to EvalStable for consistency with cuecontext
	DevVersion    = EvalV3 // TODO(mvdan): rename to EvalExperiment for consistency with cuecontext
)

type KeyValue

type KeyValue struct {
	// contains filtered or unexported fields
}

func (*KeyValue) Key

func (kv *KeyValue) Key() string

func (*KeyValue) Text

func (kv *KeyValue) Text() string

func (*KeyValue) Value

func (kv *KeyValue) Value() string

Source Files

attrs.go internal.go

Directories

PathSynopsis
internal/anyuniquePackage anyunique provides canonicalization of values under a caller-defined equivalence relation.
internal/astinternal
internal/buildattrPackage buildattr implements support for interpreting the @if build attributes in CUE files.
internal/ci
internal/ci/checks
internal/cli
internal/cmd
internal/cmd/cue-astcue-ast-print parses a CUE file and prints its syntax tree, for example:
internal/copyPackage copy provides utilities to copy files and directories.
internal/core
internal/core/adtPackage adt represents partially and fully evaluated CUE types.
internal/core/compile
internal/core/convertPackage convert allows converting to and from Go values and Types.
internal/core/debugPackage debug prints a given ADT node.
internal/core/depPackage dep analyzes dependencies between values.
internal/core/eval
internal/core/export
internal/core/formatPackage format provides functionality for pretty-printing CUE values.
internal/core/layer
internal/core/pathPackage path provides utilities for converting cue.Selectors and cue.Paths to internal equivalents.
internal/core/runtime
internal/core/subsumePackage subsume defines various subsumption relations.
internal/core/toposort
internal/core/walkwalk provides functions for visiting the nodes of an ADT tree.
internal/cueconfigPackage cueconfig holds internal API relating to CUE configuration.
internal/cuedebug
internal/cueexperiment
internal/cueimportsPackage cueimports provides support for reading the import section of a CUE file without needing to read the rest of it.
internal/cuetdtestPackage testing is a helper package for test packages in the CUE project.
internal/cuetestPackage testing is a helper package for test packages in the CUE project.
internal/cuetxtar
internal/cueversionPackage cueversion provides access to the version of the cuelang.org/go module.
internal/diff
internal/_e2e
internal/encoding
internal/encoding/gotypes
internal/encoding/json
internal/encoding/yaml
internal/envflag
internal/filetypes
internal/filetypes/internalPackage internal holds some internal parts of the filetypes package that need to be shared between the code generator and the package proper.
internal/filetypes/internal/genfunc
internal/filetypes/internal/genstructPackage genstruct provides support for simple compact struct representations.
internal/filetypes/internal/opt
internal/golangorgx
internal/golangorgx/gopls
internal/golangorgx/gopls/cmdPackage cmd handles the cuelsp command line.
internal/golangorgx/gopls/file
internal/golangorgx/gopls/hooksPackage hooks adds all the standard gopls implementations.
internal/golangorgx/gopls/lsprpcPackage lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
internal/golangorgx/gopls/progressThe progress package defines utilities for reporting the progress of long-running operations using features of the LSP client interface such as Progress and ShowMessage.
internal/golangorgx/gopls/protocolPackage protocol contains the structs that map directly to the request and response messages of the Language Server Protocol.
internal/golangorgx/gopls/protocol/commandPackage command defines the interface provided by gopls for the workspace/executeCommand LSP request.
internal/golangorgx/gopls/protocol/semtokThe semtok package provides an encoder for LSP's semantic tokens.
internal/golangorgx/gopls/settings
internal/golangorgx/gopls/test
internal/golangorgx/gopls/test/integrationPackage integration provides a framework for writing integration tests of gopls.
internal/golangorgx/gopls/test/integration/fakePackage fake provides a fake implementation of an LSP-enabled text editor, its LSP client plugin, and a Sandbox environment for use in integration tests.
internal/golangorgx/gopls/test/integration/fake/globPackage glob implements an LSP-compliant glob pattern matcher for testing.
internal/golangorgx/gopls/util
internal/golangorgx/gopls/util/browserPackage browser provides utilities for interacting with users' browsers.
internal/golangorgx/gopls/util/pathutil
internal/golangorgx/gopls/util/safetokenPackage safetoken provides wrappers around methods in go/token, that return errors rather than panicking.
internal/golangorgx/tools
internal/golangorgx/tools/diffPackage diff computes differences between text files or strings.
internal/golangorgx/tools/diff/lcspackage lcs contains code to find longest-common-subsequences (and diffs)
internal/golangorgx/tools/eventPackage event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
internal/golangorgx/tools/event/corePackage core provides support for event based telemetry.
internal/golangorgx/tools/event/export
internal/golangorgx/tools/event/export/metricPackage metric aggregates events into metrics that can be exported.
internal/golangorgx/tools/event/export/ocagentPackage ocagent adds the ability to export all telemetry to an ocagent.
internal/golangorgx/tools/event/export/ocagent/wire
internal/golangorgx/tools/event/export/prometheus
internal/golangorgx/tools/event/keys
internal/golangorgx/tools/event/label
internal/golangorgx/tools/event/tagPackage tag provides the labels used for telemetry throughout gopls.
internal/golangorgx/tools/fakenet
internal/golangorgx/tools/jsonrpc2Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
internal/golangorgx/tools/jsonrpc2/servertestPackage servertest provides utilities for running tests against a remote LSP server.
internal/golangorgx/tools/toolPackage tool is a harness for writing Go tools.
internal/httplog
internal/iterutil
internal/lsp
internal/lsp/cache
internal/lsp/definitionsDefinitions resolves paths to sets of ast.Node.
internal/lsp/fscache
internal/lsp/rangeset
internal/lsp/serverPackage server defines gopls' implementation of the LSP server interface, protocol.Server.
internal/mod
internal/mod/modfiledataPackage modfiledata holds the underlying module.cue file representation.
internal/mod/modimports
internal/mod/modload
internal/mod/modpkgload
internal/mod/modrequirements
internal/mod/modresolve
internal/mod/mvsPackage mvs implements Minimal Version Selection.
internal/mod/semverPackage semver implements comparison of semantic version strings.
internal/parPackage par implements parallel execution helpers.
internal/pkg
internal/robustioThis directory contains a copy of "golang.org/x/tools/internal/robustio", from the commit tagged with v0.34.0 (commit 578c1213983a83e6411536ddf6bbf3a1faf97aea)
internal/sourcePackage source contains utility functions that standardize reading source bytes across cue packages.
internal/taskPackage task provides a registry for tasks to be used by commands.
internal/tdtestPackage tdtest provides support for table-driven testing.
internal/types
internal/valuePackage value contains functions for converting values to internal types and various other Value-related utilities.
internal/vcsPackage vcs provides access to operations on the version control systems supported by the source field in module.cue.
Version
v0.15.1 (latest)
Published
Nov 21, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
4 months ago

Tools for package owners.