Documentation
¶
Index ¶
- func ExecuteTemplate[T any](name string, fileTemplate string, om T) string
- func ExtractPackageName(name string) string
- func GetAST(filePath string) (*ast.File, error)
- func GetDefaultPackageConfig() *packages.Config
- func GetFieldIndicator(source Field, target Field) string
- func GetFile(file ...string) string
- func GetFileName(imp string, path string, name string) string
- func GetImports(filePath string) ([]string, error)
- func GetRawType(t string) string
- func HandleCLA(input string, alt string) string
- func InferPackageFromOutputPath(outPath string) string
- func IsFullyQualifiedPackage(name string) bool
- func IsPrimitive(t string) bool
- func IsPublic(t string) bool
- func IsRefType(t string) bool
- func IsSlice(t string) bool
- func NewCSGenBuilderForFile(name string, pkg string) *strings.Builder
- func NewCSGenBuilderForOneOffFile(name string, pkg string) *strings.Builder
- func ProfileNode(node ast.Node)
- func StripPackageName(name string) string
- func WriteGeneratedGoFile(name string, contents string) error
- type Field
- type Function
- type Interface
- type Module
- type Package
- type Struct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTemplate ¶
ExecuteTemplate executes a template against a given object and return the output as a string
func ExtractPackageName ¶ added in v0.2.1
ExtractPackageName return the package name from a fully qualified name
func GetDefaultPackageConfig ¶ added in v0.6.0
GetDefaultPackageConfig return a default set of values for loading module packages
func GetFieldIndicator ¶ added in v0.2.1
GetFieldIndicator for creating an assignment operations, returns an indicator for the field based on the type of the source and target
func GetFileName ¶ added in v0.2.1
GetFileName return a file name suffixed with ".gen.go" to indicate that is was generated
func GetImports ¶
GetImports returns all of the imports in a given file
func GetRawType ¶ added in v0.2.1
GetRawType return the raw type of a type, removing the pointer, reference and slice indicators
func HandleCLA ¶ added in v0.6.5
HandleCLA the packages package has some weird behavior with a magic string called "command-line-arguments". will handle thosee cases here
func InferPackageFromOutputPath ¶ added in v0.5.0
InferPackageFromOutputPath given the output path, return the package name consistent with the deepest directory
func IsFullyQualifiedPackage ¶ added in v0.2.1
IsFullyQualifiedPackage return true if the package name is fully qualified
func IsPrimitive ¶ added in v0.2.1
IsPrimitive return true if the type is a primitive
func NewCSGenBuilderForFile ¶
NewCSGenBuilderForFile returns a string buider with a common header for generated files
func NewCSGenBuilderForOneOffFile ¶ added in v0.5.0
NewCSGenBuilderForOneOffFile returns a string buider with a common header for generated files that are indented to be modified
func ProfileNode ¶
ProfileNode get details about an unknown node based on its actual type
func StripPackageName ¶ added in v0.2.1
StripPackageName removes the package name from a fully qualified name
func WriteGeneratedGoFile ¶
WriteGeneratedGoFile create a text file with the passed in name and contents
Types ¶
type Field ¶
type Field struct { Name string Type string TagString string IsPrimitive bool IsPointer bool IsSlice bool IsPublic bool }
Field a struct that represents a single field within a struct abstraction
func GetVariables ¶
GetVariables returns a list of all variable definitions in a given file
func (*Field) GetCleanedType ¶ added in v0.6.5
GetCleanedType return a cleaned version of the type in case it includes a fully qualified namespace
type Function ¶
type Function struct { Name string Receiver *string Arguments []Field Returns []Field IsPublic bool }
Function a struct that represents a single function abstraction
func GetFunctions ¶
GetFunctions returns all of the functions in a given file
type Interface ¶
Interface a struct that represents a single interface abstraction
func GetInterfaces ¶
GetInterfaces get a list of all declared interfaces in a given file
type Module ¶ added in v0.6.0
Module represents an object graph for the entire codebase
func LoadModule ¶ added in v0.6.0
LoadModule use the "packages" package to load codebase items
func (*Module) GetPackage ¶ added in v0.6.2
GetPackage return a package from a module based on its name
type Package ¶ added in v0.6.0
type Package struct { ID string Name string FullName string Path string Files []string Structs []Struct }
Package represents an object graph for an entire package
type Struct ¶
type Struct struct { Name string FilePath string Package string Type string Fields []Field EmbeddedStructs []Struct }
Struct a struct that abstracts a golang struct
func GetStructByName ¶ added in v0.2.1
GetStructByName given a slice of structs, return one if it matches the name
func GetStructs ¶
GetStructs return a list of all structs in a given file
func (*Struct) ContainsField ¶ added in v0.2.1
ContainsField returns true if the struct contains a field with the passed in name