Documentation ¶
Index ¶
- Variables
- func GetFiles(srcPath string) ([]string, error)
- func ToDelimitedString(str string, delimiter uint8, forceUpper bool) string
- func ToLowerSnakeCase(s string) string
- func ToUpperSnakeCase(s string) string
- type AllValuesCodeBlock
- type CodeBlock
- type CodeBlockAttrs
- type CodeBlockType
- type CodeGenerator
- type CollisionStrategy
- type Config
- type Enum
- type EnumValue
- type FileWriter
- type JsonMarshalCodeBlock
- type JsonUnmarshalCodeBlock
- type LowerCamelCaseStrategy
- type LowerSnakeCaseStrategy
- type NameMapCodeBlock
- type Option
- type ParserCodeBlock
- type StdioWriter
- type StringCodeBlock
- type TestWriter
- type TransformStrategy
- type UpperCamelCaseStrategy
- type UpperSnakeCaseStrategy
- type ValueMapCodeBlock
- type Writer
Constants ¶
This section is empty.
Variables ¶
View Source
var AvailableTransformStrategy = []string{
"UPPER_SNAKE_CASE",
"lower_snake_case",
"UpperCamelCase",
"lowerCamelCase",
}
Functions ¶
func ToDelimitedString ¶ added in v0.2.0
ToDelimitedString returns string separated with delimiter Inspired by https://github.com/iancoleman/strcase
@example
- ToDelimitedString("ToDelimitedStringInSnakeCase", '.', true) -> DELIMIT.STRING.IN.SNAKE.CASE
- ToDelimitedString("ToDelimitedStringInSnakeCase", '.', false) -> delimit.string.in.snake.case
func ToLowerSnakeCase ¶ added in v0.2.0
ToLowerSnakeCase converts a string to snake_case Inspired by https://github.com/iancoleman/strcase
func ToUpperSnakeCase ¶ added in v0.2.0
ToLowerSnakeCase converts a string to SNAKE_CASE Inspired by https://github.com/iancoleman/strcase
Types ¶
type AllValuesCodeBlock ¶ added in v0.2.0
type AllValuesCodeBlock struct{}
func (AllValuesCodeBlock) Attrs ¶ added in v0.2.0
func (blk AllValuesCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (AllValuesCodeBlock) Build ¶ added in v0.2.0
func (blk AllValuesCodeBlock) Build(enum Enum) ([]byte, error)
func (AllValuesCodeBlock) Dependencies ¶ added in v0.2.0
func (blk AllValuesCodeBlock) Dependencies() []string
type CodeBlock ¶
type CodeBlock interface { // Build builds the code block. Build(enum Enum) ([]byte, error) // Dependencies returns mandatory dependencies (packages) that need to be imported Dependencies() []string // Attrs return basic attributes of the code block Attrs(enum Enum) CodeBlockAttrs }
CodeBlock is the interface to build the code block
func NewCodeBlocks ¶
type CodeBlockAttrs ¶ added in v0.2.0
type CodeBlockAttrs struct { Name string Type CodeBlockType // CollisionStrategy indicate what should we do if the code block is already exist CollisionStrategy CollisionStrategy }
type CodeBlockType ¶ added in v0.2.0
type CodeBlockType int
const ( CodeBlockTypeFunc CodeBlockType = iota CodeBlockTypeVar )
type CodeGenerator ¶
type CodeGenerator struct { // The strategy to transform name to various cases TransformStrategy TransformStrategy // Writer indicates how result should be written Writer Writer // contains filtered or unexported fields }
func NewCodeGenerator ¶
func NewCodeGenerator(opt Option) *CodeGenerator
type CollisionStrategy ¶ added in v0.2.0
type CollisionStrategy int
How should the generator do if the code block is already exist
const ( // Do nothing CollisionStrategyIgnore CollisionStrategy = iota // Relace entire code block with new one CollisionStrategyReplace )
type Enum ¶
func (Enum) AllValuesName ¶
func (Enum) NameMapName ¶
func (Enum) ValueMapName ¶
type EnumValue ¶
type EnumValue struct { goparser.EnumValue TransformStrategy TransformStrategy Trim string }
EnumValue represent an enumerated type contains raw data in a golang file and logic of code generation.
type FileWriter ¶
type FileWriter struct{}
type JsonMarshalCodeBlock ¶
type JsonMarshalCodeBlock struct{}
func (JsonMarshalCodeBlock) Attrs ¶ added in v0.2.0
func (blk JsonMarshalCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (JsonMarshalCodeBlock) Build ¶
func (blk JsonMarshalCodeBlock) Build(enum Enum) ([]byte, error)
func (JsonMarshalCodeBlock) Dependencies ¶ added in v0.2.0
func (blk JsonMarshalCodeBlock) Dependencies() []string
type JsonUnmarshalCodeBlock ¶ added in v0.2.0
type JsonUnmarshalCodeBlock struct{}
func (JsonUnmarshalCodeBlock) Attrs ¶ added in v0.2.0
func (blk JsonUnmarshalCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (JsonUnmarshalCodeBlock) Build ¶ added in v0.2.0
func (blk JsonUnmarshalCodeBlock) Build(enum Enum) ([]byte, error)
func (JsonUnmarshalCodeBlock) Dependencies ¶ added in v0.2.0
func (blk JsonUnmarshalCodeBlock) Dependencies() []string
type LowerCamelCaseStrategy ¶
type LowerCamelCaseStrategy struct{}
func (LowerCamelCaseStrategy) Run ¶
func (s LowerCamelCaseStrategy) Run(input string) string
type LowerSnakeCaseStrategy ¶
type LowerSnakeCaseStrategy struct{}
func (LowerSnakeCaseStrategy) Run ¶
func (s LowerSnakeCaseStrategy) Run(input string) string
type NameMapCodeBlock ¶ added in v0.2.0
type NameMapCodeBlock struct{}
func (NameMapCodeBlock) Attrs ¶ added in v0.2.0
func (blk NameMapCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (NameMapCodeBlock) Build ¶ added in v0.2.0
func (blk NameMapCodeBlock) Build(enum Enum) ([]byte, error)
func (NameMapCodeBlock) Dependencies ¶ added in v0.2.0
func (blk NameMapCodeBlock) Dependencies() []string
type ParserCodeBlock ¶
type ParserCodeBlock struct{}
func (ParserCodeBlock) Attrs ¶ added in v0.2.0
func (blk ParserCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (ParserCodeBlock) Dependencies ¶ added in v0.2.0
func (blk ParserCodeBlock) Dependencies() []string
type StdioWriter ¶
type StdioWriter struct{}
type StringCodeBlock ¶
type StringCodeBlock struct{}
func (StringCodeBlock) Attrs ¶ added in v0.2.0
func (blk StringCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (StringCodeBlock) Dependencies ¶ added in v0.2.0
func (blk StringCodeBlock) Dependencies() []string
type TestWriter ¶
type TestWriter struct {
Result []byte
}
TestWriter do nothing just keep a copy in the struct
type TransformStrategy ¶
The strategy to transform name to various cases
func NewTransformStrategy ¶
func NewTransformStrategy(s string) TransformStrategy
type UpperCamelCaseStrategy ¶
type UpperCamelCaseStrategy struct{}
func (UpperCamelCaseStrategy) Run ¶
func (s UpperCamelCaseStrategy) Run(input string) string
type UpperSnakeCaseStrategy ¶
type UpperSnakeCaseStrategy struct{}
func (UpperSnakeCaseStrategy) Run ¶
func (s UpperSnakeCaseStrategy) Run(input string) string
type ValueMapCodeBlock ¶
type ValueMapCodeBlock struct{}
func (ValueMapCodeBlock) Attrs ¶ added in v0.2.0
func (blk ValueMapCodeBlock) Attrs(enum Enum) CodeBlockAttrs
func (ValueMapCodeBlock) Dependencies ¶ added in v0.2.0
func (blk ValueMapCodeBlock) Dependencies() []string
Click to show internal directories.
Click to hide internal directories.