Back to godoc.org

Package appproto

v0.20.5
Latest Go to latest

The latest major version is .

Published: Jul 24, 2020 | License: Apache-2.0 | Module: github.com/bufbuild/buf

Overview

Package appproto contains helper functionality for protoc plugins.

Index

func Execute

func Execute(
	ctx context.Context,
	container app.EnvStderrContainer,
	handler Handler,
	request *pluginpb.CodeGeneratorRequest,
) (*pluginpb.CodeGeneratorResponse, error)

Execute executes the given handler.

func NewRunFunc

func NewRunFunc(handler Handler) func(context.Context, app.Container) error

NewRunFunc returns a new RunFunc for app.Main and app.Run.

type Handler

type Handler interface {
	// Handle handles the plugin.
	//
	// This function can assume the request is valid.
	Handle(
		ctx context.Context,
		container app.EnvStderrContainer,
		responseWriter ResponseWriter,
		request *pluginpb.CodeGeneratorRequest,
	) error
}

Handler is a protoc plugin handler

type HandlerFunc

type HandlerFunc func(
	context.Context,
	app.EnvStderrContainer,
	ResponseWriter,
	*pluginpb.CodeGeneratorRequest,
) error

HandlerFunc is a handler function.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(
	ctx context.Context,
	container app.EnvStderrContainer,
	responseWriter ResponseWriter,
	request *pluginpb.CodeGeneratorRequest,
) error

Handle implements Handler.

type ResponseWriter

type ResponseWriter interface {
	// Add adds the file to the response.
	//
	// Returns error if nil, the name is empty, or the name is already added.
	Add(*pluginpb.CodeGeneratorResponse_File) error
	// AddError adds the error message to the response.
	//
	// If there is an existing error message, this will be concatenated with a newline.
	AddError(message string) error
	// SetFeatureProto3Optional sets the proto3 optional feature.
	SetFeatureProto3Optional()
}

ResponseWriter handles CodeGeneratorResponses.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier