svctool

package
v0.0.0-...-4a11b79 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package svctool implements svcmux/svcdec tools command line parsing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator func(c context.Context, a *GeneratorArgs) error

type GeneratorArgs

type GeneratorArgs struct {
	PackageName  string
	Services     []*Service
	ExtraImports []Import
	Out          io.Writer
}

GeneratorArgs is passed to the function responsible for generating files.

type Import

type Import struct {
	Name string
	Path string
}

type Method

type Method struct {
	Name       string
	Node       *ast.Field
	InputType  string
	OutputType string
}

type Service

type Service struct {
	TypeName string
	Node     *ast.InterfaceType
	Methods  []*Method
}

Service contains the result of parsing the generated code for a pRPC service.

type Tool

type Tool struct {
	// Name of the tool, e.g. "svcmux" or "svcdec".
	Name string
	// OutputFilenameSuffix is the suffix of generated file names,
	// e.g. "mux" or "dec" for foo_mux.go or foo_dec.go.
	OutputFilenameSuffix string

	// Types are type names from the Go package defined by Dir or FileNames.
	Types []string
	// Output is the base name for the output file.
	Output string
	// Dir is a Go package's directory.
	Dir string
	// FileNames is a list of source files from a single Go package.
	FileNames []string
}

Tool is a helper class for svcmux and svcdec.

func (*Tool) Main

func (t *Tool) Main(args []string, f Generator)

Main does some setup (arg parsing, logging), calls t.Run, prints any errors and exits.

func (*Tool) ParseArgs

func (t *Tool) ParseArgs(args []string)

ParseArgs parses command arguments. Exits if they are invalid.

func (*Tool) Run

func (t *Tool) Run(c context.Context, f Generator) error

Run parses Go files and generates a new file using f.

Jump to

Keyboard shortcuts

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