generate

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOrDownloadProtoc

func CheckOrDownloadProtoc(path, version string) (string, error)

CheckOrDownloadProtoc downloads protoc to the specified path, unless it's already been downloaded. If no path is provided, it uses an OS-appropriate user cache. If the version is not specified, the latest version is fetched from GitHub. If both version and path are specified and a file already exists at the path, it checks whether the output of `protoc --version` is an exact match.

Note that this code is safe for concurrent use between multiple goroutines or processes, since it uses a lock file on disk.

func FileDescriptorSet

func FileDescriptorSet(dir string, args ...string) (*desc.FileDescriptorSet, error)

FileDescriptorSet will load a single Gunk package, and return the proto FileDescriptor set of the Gunk package.

Currently, we only generate a FileDescriptorSet for one Gunk package.

func Run

func Run(dir string, args ...string) error

Run generates the specified Gunk packages via protobuf generators, writing the output files in the same directories.

Types

type Generator

type Generator struct {
	loader.Loader
	// contains filtered or unexported fields
}

func (*Generator) GeneratePkg

func (g *Generator) GeneratePkg(path string, gens []config.Generator, protocPath string) error

GeneratePkg runs the proto files resulting from translating gunk packages through a code generator, such as protoc-gen-go to generate Go packages.

Generated files are written to the same directory, next to the source gunk files.

It is fine to pass the plugin.CodeGeneratorRequest to every protoc generator unaltered; this is what protoc does when calling out to the generators and the generators should already handle the case where they have nothing to do.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL