Back to godoc.org

Package svctool

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Overview

Package svctool implements svcmux/svcdec tools command line parsing

Index

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.

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