Documentation ¶
Overview ¶
Package plugin provides the ability to implement extension functionality using plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Plugins = []Plugin{ &Swagger{}, &OpenAPI{}, &Validate{}, sync.NewGit(sync.DefaultFileManager, sync.DefaultGitManager, sync.AuthSupplier), }
Plugins is the chain of public plugins.
var PluginsExt = map[string][]Plugin{ "go": { &GoImports{}, &Formatter{}, &GoMock{}, &GoTag{}, }, "cpp": { &CppMove{}, }, }
PluginsExt is the language-specific plugin chain.
Functions ¶
This section is empty.
Types ¶
type CppMove ¶
type CppMove struct { }
CppMove is the plugin for moving proto files to proto directory in generated project.
func (*CppMove) Check ¶
func (p *CppMove) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when `--lang=cpp`
func (*CppMove) Run ¶
func (p *CppMove) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run runs moving directories action.
type Formatter ¶
type Formatter struct { }
Formatter is a plugin used to format generated code.
func (*Formatter) Check ¶
func (p *Formatter) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check don't run if `--lang != go`
func (*Formatter) Run ¶
func (p *Formatter) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run runs gofmt action.
type GoImports ¶
type GoImports struct{}
GoImports is goimports plugin.
func (*GoImports) Check ¶
func (p *GoImports) Check(_ *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when `--lang=go && --goimports=true`
func (*GoImports) Run ¶
func (p *GoImports) Run(_ *descriptor.FileDescriptor, _ *params.Option) error
Run runs goimports action.
type GoMock ¶
type GoMock struct { }
GoMock is gomock plugin.
func (*GoMock) Check ¶
func (p *GoMock) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when `--lang=go || --mockgen=true`
func (*GoMock) Run ¶
func (p *GoMock) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run runs mockgen action.
type GoTag ¶
type GoTag struct { }
GoTag generates go tag by proto field options
func (*GoTag) Check ¶
func (p *GoTag) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when `--lang=go && --go_tag=true`
func (*GoTag) Run ¶
func (p *GoTag) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run exec go tag plugin
type OpenAPI ¶
type OpenAPI struct { }
OpenAPI is swagger plugin.
func (*OpenAPI) Check ¶
func (p *OpenAPI) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when `--openapi=true`
func (*OpenAPI) Run ¶
func (p *OpenAPI) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run runs openapi action to generate openapi apidocs
type Plugin ¶
type Plugin interface { // Name return plugin's name. Name() string // Check return whether this plugin should be run. Check(fd *descriptor.FileDescriptor, opt *params.Option) bool // Run runs plugin. Run(fd *descriptor.FileDescriptor, opt *params.Option) error }
Plugin represents some customized operation.
type Swagger ¶
type Swagger struct { }
Swagger is swagger plugin.
func (*Swagger) Check ¶
func (p *Swagger) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check run only when `--swagger=true`
func (*Swagger) Run ¶
func (p *Swagger) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run run swagger plugin to generate swagger apidocs
type Validate ¶
type Validate struct { }
Validate is validate plugin.
func (*Validate) Check ¶
func (p *Validate) Check(fd *descriptor.FileDescriptor, opt *params.Option) bool
Check only run when language is supported.
func (*Validate) Run ¶
func (p *Validate) Run(fd *descriptor.FileDescriptor, opt *params.Option) error
Run runs protoc-gen-validate to generate validate.pb.go
Only supports a few programming languages. See: https://trpc.group/devsec/protoc-gen-secv