go: cuelang.org/go/internal/encoding Index | Files | Directories

package encoding

import "cuelang.org/go/internal/encoding"


Package Files

detect.go encoder.go encoding.go

func Detect Uses

func Detect(v cue.Value) (i build.Interpretation)

Detect detects the interpretation.

type Config Uses

type Config struct {
    Mode filetypes.Mode

    // Out specifies an overwrite destination.
    Out    io.Writer
    Stdin  io.Reader
    Stdout io.Writer

    PkgName string // package name for files to generate

    Force     bool // overwrite existing files.
    Strict    bool
    Stream    bool // will potentially write more than one document per file
    AllErrors bool

    EscapeHTML bool
    ProtoPath  []string
    Format     []format.Option
    ParseFile  func(name string, src interface{}) (*ast.File, error)

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields

func NewDecoder Uses

func NewDecoder(f *build.File, cfg *Config) *Decoder

NewDecoder returns a stream of non-rooted data expressions. The encoding type of f must be a data type, but does not have to be an encoding that can stream. stdin is used in case the file is "-".

func (*Decoder) Close Uses

func (i *Decoder) Close()

func (*Decoder) Done Uses

func (i *Decoder) Done() bool

func (*Decoder) Err Uses

func (i *Decoder) Err() error

func (*Decoder) File Uses

func (i *Decoder) File() *ast.File

func (*Decoder) Filename Uses

func (i *Decoder) Filename() string

func (*Decoder) ID Uses

func (i *Decoder) ID() string

ID returns a canonical identifier for the decoded object or "" if no such identifier could be found.

func (*Decoder) Index Uses

func (i *Decoder) Index() int

func (*Decoder) Interpretation Uses

func (i *Decoder) Interpretation() build.Interpretation

Interpretation returns the current interpretation detected by Detect.

func (*Decoder) Next Uses

func (i *Decoder) Next()

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields

An Encoder converts CUE to various file formats, including CUE itself. An Encoder allows

func NewEncoder Uses

func NewEncoder(f *build.File, cfg *Config) (*Encoder, error)

NewEncoder writes content to the file with the given specification.

func (Encoder) Close Uses

func (e Encoder) Close() error

func (*Encoder) Encode Uses

func (e *Encoder) Encode(inst *cue.Instance) error

func (*Encoder) EncodeFile Uses

func (e *Encoder) EncodeFile(f *ast.File) error

func (*Encoder) IsConcrete Uses

func (e *Encoder) IsConcrete() bool

IsConcrete reports whether the output is required to be concrete.

INTERNAL ONLY: this is just to work around a problem related to issue #553 of catching errors ony after syntax generation, dropping line number information.



Package encoding imports 27 packages (graph) and is imported by 3 packages. Updated 2021-01-26. Refresh now. Tools for package owners.