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

package protobuf

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

Package protobuf defines functionality for parsing protocol buffer definitions and instances.

TODO: this package can become public once we have found a good nest for it.

Index

Functions

func Parse

func Parse(filename string, body io.Reader, c *Config) (f *ast.File, err error)

Parse parses a single proto file and returns its contents translated to a CUE file. Imports are resolved using the path define in Config. If body is not nil, it will use this as the contents of the file. Otherwise Parse will open the given file name at the fully qualified path.

The following field options are supported:

(cue.val)     string        CUE constraint for this field. The string may
                            refer to other fields in a message definition.
(cue.opt)     FieldOptions
   required   bool          Defines the field is required. Use with
                            caution.

Types

type Config

type Config struct {
	Paths []string
}

Config specifies the environment into which to parse a proto definition file.

type Error

type Error struct {
	Filename string
	Path     string
	Err      error
}

Error describes the location and cause of an error.

func (*Error) Error

func (p *Error) Error() string

func (*Error) Unwrap

func (p *Error) Unwrap() error

Source Files

parse.go protobuf.go types.go util.go

Version
v0.0.2
Published
Jun 22, 2019
Platform
windows/amd64
Imports
13 packages
Last checked
7 minutes ago

Tools for package owners.