plugin

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 29 Imported by: 0

Documentation

Overview

Package plugin provides the ability to implement extension functionality using plugins.

Index

Constants

This section is empty.

Variables

Plugins is the chain of public plugins.

View Source
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) Name

func (p *CppMove) Name() string

Name returns the plugin name.

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) Name

func (p *Formatter) Name() string

Name return plugin's name.

func (*Formatter) Run

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) Name

func (p *GoImports) Name() string

Name return plugin's name.

func (*GoImports) Run

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) Name

func (p *GoMock) Name() string

Name return plugin's name.

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) Name

func (p *GoTag) Name() string

Name return plugin's name

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) Name

func (p *OpenAPI) Name() string

Name return plugin's name.

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) Name

func (p *Swagger) Name() string

Name return plugin's name.

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) Name

func (p *Validate) Name() string

Name return plugin's name.

func (*Validate) Run

Run runs protoc-gen-validate to generate validate.pb.go

Only supports a few programming languages. See: https://trpc.group/devsec/protoc-gen-secv

Directories

Path Synopsis
Package sync is a generated GoMock package.
Package sync is a generated GoMock package.

Jump to

Keyboard shortcuts

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