gogencli

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 12 Imported by: 0

README

gogencli

Author

Rangel Reale ([email protected])

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTypeName

func ParseTypeName(typeName string) (pkg string, name string)

Types

type ASTHelper

type ASTHelper struct {
	// contains filtered or unexported fields
}

func NewASTHelper

func NewASTHelper(g *Generator) *ASTHelper

func (*ASTHelper) FindFileByFilename

func (u *ASTHelper) FindFileByFilename(pkg *packages.Package, filename string) *ast.File

func (*ASTHelper) FindType

func (u *ASTHelper) FindType(typ string) *ASTType

func (*ASTHelper) FindTypeInFile

func (u *ASTHelper) FindTypeInFile(pkg *packages.Package, file *ast.File, name string) *ASTType

func (*ASTHelper) FindTypeInFilePath

func (u *ASTHelper) FindTypeInFilePath(pkg *packages.Package, filename string, name string) *ASTType

func (*ASTHelper) FindTypeInPackage

func (u *ASTHelper) FindTypeInPackage(pkg *packages.Package, name string) *ASTType

func (*ASTHelper) FindTypeWithError

func (u *ASTHelper) FindTypeWithError(typ string) (*ASTType, error)

func (*ASTHelper) FindTypes

func (u *ASTHelper) FindTypes(types ...string) (ASTTypeList, error)

func (*ASTHelper) ToTypes

func (u *ASTHelper) ToTypes(pkg *packages.Package, node ast.Node) types.Object

type ASTType

type ASTType struct {
	Name    string
	Package *packages.Package
	File    *ast.File
	Decl    ast.Decl
	Spec    ast.Spec
}

type ASTTypeList

type ASTTypeList []*ASTType

func (ASTTypeList) ByPackage

func (l ASTTypeList) ByPackage() []*DataWithPackage[[]*ASTType]

func (ASTTypeList) Named

func (l ASTTypeList) Named(name string) *ASTType

type DataWithPackage

type DataWithPackage[T any] struct {
	Package *packages.Package
	Data    T
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func New

func New(options ...Option) (*Generator, error)

func (*Generator) ASTHelper

func (g *Generator) ASTHelper() *ASTHelper

func (*Generator) FindPackageByPath

func (g *Generator) FindPackageByPath(pkgPath string) *packages.Package

func (*Generator) GoFile

func (g *Generator) GoFile() string

func (*Generator) GoLine

func (g *Generator) GoLine() int

func (*Generator) GoPackage

func (g *Generator) GoPackage() string

func (*Generator) IsGoGenerateLine

func (g *Generator) IsGoGenerateLine(node ast.Node) bool

func (*Generator) Packages

func (g *Generator) Packages() []*packages.Package

func (*Generator) Patterns

func (g *Generator) Patterns() []string

func (*Generator) Root

func (g *Generator) Root() *Root

func (*Generator) RootDir

func (g *Generator) RootDir() string

func (*Generator) RootPackage

func (g *Generator) RootPackage() *packages.Package

func (*Generator) TypesHelper

func (g *Generator) TypesHelper() *TypesHelper

type Option

type Option func(*Generator) error

func WithAddRootPattern

func WithAddRootPattern(addRoot bool) Option

func WithDefaultValues

func WithDefaultValues(goPackage string, goFile string, goLine int) Option

func WithDefaults

func WithDefaults() Option

func WithPackagesConfig

func WithPackagesConfig(config *packages.Config) Option

func WithPatterns

func WithPatterns(patterns ...string) Option

func WithRootDir

func WithRootDir(rootDir string) Option

func WithRootRequired

func WithRootRequired(required bool) Option

type Root

type Root struct {
	ASTFile   *ast.File
	TokenFile *token.File

	Decl   *ASTType
	Object types.Object
}

type TypesHelper

type TypesHelper struct {
	// contains filtered or unexported fields
}

func NewTypesHelper

func NewTypesHelper(g *Generator) *TypesHelper

func (*TypesHelper) FindType

func (u *TypesHelper) FindType(typ string) *TypesType

func (*TypesHelper) FindTypeWithError

func (u *TypesHelper) FindTypeWithError(typ string) (*TypesType, error)

func (*TypesHelper) FindTypes

func (u *TypesHelper) FindTypes(types ...string) (TypesList, error)

func (*TypesHelper) ToAST

func (u *TypesHelper) ToAST(obj types.Object) (*ASTType, error)

func (*TypesHelper) ToPackage

func (u *TypesHelper) ToPackage(pkg *types.Package) *packages.Package

type TypesList

type TypesList []*TypesType

func (TypesList) ByPackage

func (l TypesList) ByPackage() []*DataWithPackage[[]*TypesType]

func (TypesList) Named

func (l TypesList) Named(name string) *TypesType

type TypesType

type TypesType struct {
	Name    string
	Package *packages.Package
	Obj     types.Object
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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