Documentation
¶
Index ¶
- func BuildPluginCmd(args *Argument) (*exec.Cmd, error)
- func IdlTypeToCompiler(idlType string) (string, error)
- type Argument
- func (arg *Argument) Fork() *Argument
- func (arg *Argument) GetClientDir() (string, error)
- func (arg *Argument) GetGoPackage() (string, error)
- func (arg *Argument) GetHandlerDir() (string, error)
- func (arg *Argument) GetModelDir() (string, error)
- func (arg *Argument) GetRouterDir() (string, error)
- func (arg *Argument) GetThriftgoOptions() (string, error)
- func (arg *Argument) InitManifest(m *meta.Manifest)
- func (arg *Argument) IsNew() bool
- func (arg *Argument) IsUpdate() bool
- func (arg *Argument) ModelOutDir() string
- func (arg *Argument) ModelPackagePrefix() (string, error)
- func (arg *Argument) Pack() ([]string, error)
- func (arg *Argument) Parse(c *cli.Context, cmd string) (*Argument, error)
- func (arg *Argument) Unpack(data []string) error
- func (arg *Argument) UpdateByManifest(m *meta.Manifest)
- func (arg *Argument) UpdateManifest(m *meta.Manifest)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPluginCmd ¶
BuildPluginCmd constructs the protoc/thriftgo command that invokes the current hz binary as a plugin. The hz binary re-enters as a plugin via PluginMode() (detected by EnvPluginMode). Arguments are serialized via PackArgs and passed as comma-separated key=value pairs.
func IdlTypeToCompiler ¶
Types ¶
type Argument ¶
type Argument struct {
// Mode meta.Mode // operating mode(0-compiler, 1-plugin)
CmdType string // command type
Verbose bool // print verbose log
Cwd string // execution path
OutDir string // output path
HandlerDir string // handler path
ModelDir string // model path
RouterDir string // router path
ClientDir string // client path
BaseDomain string // request domain
ForceClientDir string // client dir (not use namespace as a subpath)
IdlType string // idl type
IdlPaths []string // master idl path
RawOptPkg []string // user-specified package import path
OptPkgMap map[string]string
Includes []string
PkgPrefix string
TrimGoPackage string // trim go_package for protobuf, avoid to generate multiple directory
Gopath string // $GOPATH
Gosrc string // $GOPATH/src
Gomod string
Gopkg string // $GOPATH/src/{{gopkg}}
ServiceName string // service name
Use string
NeedGoMod bool
JSONEnumStr bool
QueryEnumAsInt bool
UnsetOmitempty bool
ProtobufCamelJSONTag bool
ProtocOptions []string // options to pass through to protoc
ThriftOptions []string // options to pass through to thriftgo for go flag
ProtobufPlugins []string
ThriftPlugins []string
SnakeName bool
RmTags []string
Excludes []string
NoRecurse bool
HandlerByMethod bool
ForceNew bool
ForceUpdateClient bool
SnakeStyleMiddleware bool
EnableExtends bool
SortRouter bool
// client flag
EnableClientOptional bool
CustomizeLayout string
CustomizeLayoutData string
CustomizePackage string
ModelBackend string
}
func NewArgument ¶
func NewArgument() *Argument
func (*Argument) Fork ¶
Fork creates a deep copy of the argument. This is necessary because globalArgs is shared across CLI commands and its slice/map fields would otherwise be mutated.
func (*Argument) GetClientDir ¶
func (*Argument) GetGoPackage ¶
func (*Argument) GetHandlerDir ¶
func (*Argument) GetModelDir ¶
func (*Argument) GetRouterDir ¶
func (*Argument) GetThriftgoOptions ¶
GetThriftgoOptions builds the thriftgo "-g go:..." option string. It starts with default options (reserve_comments, no auto json tags) and appends user-specified options plus the computed package prefix.
func (*Argument) InitManifest ¶ added in v0.6.0
func (*Argument) ModelOutDir ¶
func (*Argument) ModelPackagePrefix ¶
ModelPackagePrefix returns the Go import path prefix for generated model packages. This is passed to thriftgo so it generates import paths matching our output structure.
func (*Argument) Pack ¶
Pack serializes the argument to a string list for passing through the protoc/thriftgo plugin interface (see util.PackArgs).