template

package
v0.0.0-...-1ba222c Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProtoCmd = &cli.Command{
	Name:        "proto",
	Description: "Generate proto file",
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "methods", Aliases: []string{"m"}, Usage: "service method name, like \"User,Login\" (,)separated"},
		&cli.StringFlag{Name: "service", Aliases: []string{"s"}, DefaultText: "service", Value: "service", Usage: "service name, like backend"},
		&cli.StringFlag{Name: "api-key", Aliases: []string{"k"}, DefaultText: "api_key", Value: "api_key", Usage: "http auth key name"},
		&cli.StringFlag{Name: "path", Aliases: []string{"p"}, DefaultText: "./", Usage: "generate proto file path"},
		&cli.StringFlag{Name: "version", Aliases: []string{"v"}, DefaultText: "v1", Value: "v1"},
		&cli.BoolFlag{Name: "auth", Aliases: []string{"a"}, Usage: "generate api auth security option"},
		&cli.BoolFlag{Name: "gen-ent", Aliases: []string{"e"}, Usage: "generate ent option"},
	},
	Action: protoRun,
}
View Source
var ServiceCmd = &cli.Command{
	Name: "service",
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "proto", Aliases: []string{"p"}, Usage: "proto file", Required: true},
		&cli.StringFlag{Name: "target_dir", Aliases: []string{"t"}, DefaultText: "internal/service", Value: "internal/service"},
	},
	Action: serviceRun,
}

Functions

This section is empty.

Types

type Method

type Method struct {
	Service string
	Name    string
	Request string
	Reply   string
	Uri     string

	// type: unary or stream
	Type MethodType
}

Method is a proto method.

type MethodType

type MethodType uint8

type Proto

type Proto struct {
	Methods  []Method
	Path     string
	ApiKey   string
	Service  string
	Uri      string
	Version  string
	IsAuth   bool
	IsGenEnt bool
}

Proto is a proto generator.

func (*Proto) Generate

func (p *Proto) Generate() error

Generate generate a proto template.

type Service

type Service struct {
	Package     string
	Biz         string
	Service     string
	Methods     []*Method
	GoogleEmpty bool

	UseIO      bool
	UseContext bool
}

Service is a proto service.

Jump to

Keyboard shortcuts

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