go: cuelang.org/go/cue/load Index | Files

package load

import "cuelang.org/go/cue/load"

Package load loads CUE instances.


Package Files

config.go doc.go errors.go fs.go import.go loader.go match.go package.go read.go search.go source.go


const FromArgsUsage = "" /* 2864 byte string literal not displayed */

FromArgsUsage is a partial usage message that applications calling FromArgs may wish to include in their -help output.

Some of the aspects of this documentation, like flags and handling '--' need to be implemented by the tools.

func GenPath Uses

func GenPath(root string) string

GenPath reports the directory in which to store generated files.

func Instances Uses

func Instances(args []string, c *Config) []*build.Instance

Instances returns the instances named by the command line arguments 'args'. If errors occur trying to load an instance it is returned with Incomplete set. Errors directly related to loading the instance are recorded in this instance, but errors that occur loading dependencies are recorded in these dependencies.

type Config Uses

type Config struct {
    // Context specifies the context for the load operation.
    // If the context is cancelled, the loader may stop early
    // and return an ErrCancelled error.
    // If Context is nil, the load cannot be cancelled.
    Context *build.Context

    // A Module is a collection of packages and instances that are within the
    // directory hierarchy rooted at the module root. The module root can be
    // marked with a cue.mod file.
    ModuleRoot string

    // Module specifies the module prefix. If not empty, this value must match
    // the module field of an existing cue.mod file.
    Module string

    // Package defines the name of the package to be loaded. In this is not set,
    // the package must be uniquely defined from its context.
    Package string

    // Dir is the directory in which to run the build system's query tool
    // that provides information about the packages.
    // If Dir is empty, the tool is run in the current directory.
    Dir string

    // The build and release tags specify build constraints that should be
    // considered satisfied when processing +build lines. Clients creating a new
    // context may customize BuildTags, which defaults to empty, but it is
    // usually an error to customize ReleaseTags, which defaults to the list of
    // CUE releases the current release is compatible with.
    BuildTags []string

    // If Tests is set, the loader includes not just the packages
    // matching a particular pattern but also any related test packages.
    Tests bool

    // If Tools is set, the loader includes tool files associated with
    // a package.
    Tools bool

    // If DataFiles is set, the loader includes entries for directories that
    // have no CUE files, but have recognized data files that could be converted
    // to CUE.
    DataFiles bool

    // StdRoot specifies an alternative directory for standard libaries.
    // This is mostly used for bootstrapping.
    StdRoot string

    // ParseFile is called to read and parse each file when preparing a
    // package's syntax tree. It must be safe to call ParseFile simultaneously
    // from multiple goroutines. If ParseFile is nil, the loader will uses
    // parser.ParseFile.
    // ParseFile should parse the source from src and use filename only for
    // recording position information.
    // An application may supply a custom implementation of ParseFile to change
    // the effective file contents or the behavior of the parser, or to modify
    // the syntax tree.
    ParseFile func(name string, src interface{}) (*ast.File, error)

    // Overlay provides a mapping of absolute file paths to file contents.
    // If the file  with the given path already exists, the parser will use the
    // alternative file contents provided by the map.
    // If the value must be of type string, []byte, io.Reader, or *ast.File.
    Overlay map[string]Source

    // Stdin defines an alternative for os.Stdin for the file "-". When used,
    // the corresponding build.File will be associated with the full buffer.
    Stdin io.Reader
    // contains filtered or unexported fields

A Config configures load behavior.

type MultiplePackageError Uses

type MultiplePackageError struct {
    Dir      string   // directory containing files
    Packages []string // package names found
    Files    []string // corresponding files: Files[i] declares package Packages[i]

MultiplePackageError describes an attempt to build a package composed of CUE files from different packages.

func (*MultiplePackageError) Error Uses

func (e *MultiplePackageError) Error() string

func (*MultiplePackageError) InputPositions Uses

func (e *MultiplePackageError) InputPositions() []token.Pos

func (*MultiplePackageError) Msg Uses

func (e *MultiplePackageError) Msg() (string, []interface{})

func (*MultiplePackageError) Path Uses

func (e *MultiplePackageError) Path() []string

func (*MultiplePackageError) Position Uses

func (e *MultiplePackageError) Position() token.Pos

type NoFilesError Uses

type NoFilesError struct {
    Package *build.Instance
    // contains filtered or unexported fields

NoFilesError is the error used by Import to describe a directory containing no usable source files. (It may still contain tool files, files hidden by build tags, and so on.)

func (*NoFilesError) Error Uses

func (e *NoFilesError) Error() string


func (*NoFilesError) InputPositions Uses

func (e *NoFilesError) InputPositions() []token.Pos

func (*NoFilesError) Msg Uses

func (e *NoFilesError) Msg() (string, []interface{})


func (*NoFilesError) Path Uses

func (e *NoFilesError) Path() []string

func (*NoFilesError) Position Uses

func (e *NoFilesError) Position() token.Pos

type PackageError Uses

type PackageError struct {
    ImportStack    []string  // shortest path from package named on command line to this one
    Pos            token.Pos // position of error
    errors.Message           // the error itself
    IsImportCycle  bool      // the error is an import cycle

A PackageError describes an error loading information about a package.

func (*PackageError) Error Uses

func (p *PackageError) Error() string


func (*PackageError) InputPositions Uses

func (p *PackageError) InputPositions() []token.Pos

func (*PackageError) Path Uses

func (p *PackageError) Path() []string

func (*PackageError) Position Uses

func (p *PackageError) Position() token.Pos

type Source Uses

type Source interface {
    // contains filtered or unexported methods

A Source represents file contents.

func FromBytes Uses

func FromBytes(b []byte) Source

FromBytes creates a Source from the given bytes. The contents are not copied and should not be modified.

func FromFile Uses

func FromFile(f *ast.File) Source

FromFile creates a Source from the given *ast.File. The file should not be modified. It is assumed the file is error-free.

func FromString Uses

func FromString(s string) Source

FromString creates a Source from the given string.

Package load imports 29 packages (graph) and is imported by 4 packages. Updated 2020-08-01. Refresh now. Tools for package owners.