Documentation ¶
Index ¶
- func Append(s *string, args ...string)
- func Camel2Case(name string) string
- func CamelCase(s string) string
- func CodeFormat(buf *bytes.Buffer) (string, error)
- func DefaultAPIOptions(pkg, srv, mth string) *options.HttpRule
- func ExtractAPIOptions(mth protoreflect.MethodDescriptor) (*options.HttpRule, error)
- func ExtractHttpMethod(opts *options.HttpRule) (method, path string)
- func Gen(g *protogen.GeneratedFile, tpl string, m pongo.Context)
- func ID(s string) string
- func Import(name string) func(id string) protogen.GoIdent
- func IsHelp() bool
- func Template(tpl string, m pongo.Context) string
- func UnExport(s string) string
- type Context
- type FilePath
- func (n FilePath) Base() string
- func (n FilePath) BaseName() string
- func (n FilePath) Dir() FilePath
- func (n FilePath) Ext() string
- func (n FilePath) Pop() FilePath
- func (n FilePath) Push(elem string) FilePath
- func (n FilePath) SetBase(base string) FilePath
- func (n FilePath) SetExt(ext string) FilePath
- func (n FilePath) String() string
- type Name
- func (n Name) LowerCamelCase() Name
- func (n Name) LowerDotNotation() Name
- func (n Name) LowerSnakeCase() Name
- func (n Name) ScreamingSnakeCase() Name
- func (n Name) SnakeCase() Name
- func (n Name) Split() (parts []string)
- func (n Name) String() string
- func (n Name) Transform(mod, first NameTransformer, sep string) Name
- func (n Name) UpperCamelCase() Name
- func (n Name) UpperDotNotation() Name
- func (n Name) UpperSnakeCase() Name
- type NameTransformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶ added in v0.0.13
CamelCase returns the CamelCased name. If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.
func CodeFormat ¶ added in v0.0.13
CodeFormat go code format
func DefaultAPIOptions ¶ added in v0.0.13
DefaultAPIOptions This generates an HttpRule that matches the gRPC mapping to HTTP/2 described in https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests i.e.:
- method is POST
- path is "<pkg name>/<service name>/<method name>"
- body should contain the serialized request message
func ExtractAPIOptions ¶ added in v0.0.13
func ExtractAPIOptions(mth protoreflect.MethodDescriptor) (*options.HttpRule, error)
func ExtractHttpMethod ¶ added in v0.0.13
Types ¶
type FilePath ¶ added in v0.0.13
type FilePath string
A FilePath describes the name of a file or directory. This type simplifies path related operations.
func JoinPaths ¶ added in v0.0.13
JoinPaths is an convenient alias around filepath.Join, to easily create FilePath types.
func (FilePath) Base ¶ added in v0.0.13
Base returns the base of the current FilePath (the last element in the path). This method is an alias around filepath.Base.
func (FilePath) BaseName ¶ added in v0.0.13
BaseName returns the Base of the current FilePath without Ext.
func (FilePath) Dir ¶ added in v0.0.13
Dir returns the parent directory of the current FilePath. This method is an alias around filepath.Dir.
func (FilePath) Ext ¶ added in v0.0.13
Ext returns the extension of the current FilePath (starting at and including the last '.' in the FilePath). This method is an alias around filepath.Ext.
func (FilePath) Pop ¶ added in v0.0.13
Pop returns a new FilePath with the last element removed. Pop is an alias for the Dir method.
func (FilePath) SetBase ¶ added in v0.0.13
SetBase returns a new FilePath with the base element replaced with base.
type Name ¶ added in v0.0.13
type Name string
A Name describes an identifier of an Entity (Message, Field, Enum, Service, Field). It can be converted to multiple forms using the provided helper methods, or a custom transform can be used to modify its behavior.
func (Name) LowerCamelCase ¶ added in v0.0.13
LowerCamelCase converts Name n to lower camelcase, where each part is title-cased and concatenated with no separator except the first which is lower-cased.
func (Name) LowerDotNotation ¶ added in v0.0.13
LowerDotNotation converts Name n to lower dot notation, where each part is lower-cased and concatenated with periods.
func (Name) LowerSnakeCase ¶ added in v0.0.13
LowerSnakeCase converts Name n to lower-snake-case, where each part is lower-cased and concatenated with underscores.
func (Name) ScreamingSnakeCase ¶ added in v0.0.13
ScreamingSnakeCase converts Name n to screaming-snake-case, where each part is all-caps and concatenated with underscores.
func (Name) SnakeCase ¶ added in v0.0.13
SnakeCase converts Name n to snake-case, where each part preserves its capitalization and concatenated with underscores.
func (Name) Split ¶ added in v0.0.13
Split breaks apart Name n into its constituent components. Precedence follows dot notation, then underscores (excluding underscore prefixes), then camelcase. Numbers are treated as standalone components.
func (Name) Transform ¶ added in v0.0.13
func (n Name) Transform(mod, first NameTransformer, sep string) Name
Transform applies a transformation to the parts of Name n, returning a new Name. Transformer first is applied to the first part, with mod applied to all subsequent ones. The parts are then concatenated with the separator sep. For optimal efficiency, multiple NameTransformers should be Chained together before calling Transform.
func (Name) UpperCamelCase ¶ added in v0.0.13
UpperCamelCase converts Name n to upper camelcase, where each part is title-cased and concatenated with no separator.
func (Name) UpperDotNotation ¶ added in v0.0.13
UpperDotNotation converts Name n to upper dot notation, where each part is title-cased and concatenated with periods.
func (Name) UpperSnakeCase ¶ added in v0.0.13
UpperSnakeCase converts Name n to upper-snake-case, where each part is title-cased and concatenated with underscores.
type NameTransformer ¶ added in v0.0.13
NameTransformer is a function that mutates a string. Many of the methods in the standard strings package satisfy this signature.
func (NameTransformer) Chain ¶ added in v0.0.13
func (n NameTransformer) Chain(t NameTransformer) NameTransformer
Chain combines the behavior of two Transformers into one. If multiple transformations need to be performed on a Name, this method should be used to reduce it to a single transformation before applying.