ast

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAstParse   = errors.New("ast parse error")
	ErrFieldParse = fmt.Errorf("parse field: %w", ErrAstParse)
)

Functions

func Walk

func Walk(n ast.Node, fset *token.FileSet, h FileHandler)

Types

type CommentHandler

type CommentHandler interface {
	// contains filtered or unexported methods
}

type CommentSpec

type CommentSpec struct {
	Text string
	Line int
}

type DocHandler

type DocHandler interface {
	// contains filtered or unexported methods
}

type DocSpec

type DocSpec struct {
	Doc string
}

type FieldCollector

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

type FieldHandler

type FieldHandler interface {
	// contains filtered or unexported methods
}

type FieldSpec

type FieldSpec struct {
	Names   []string
	Doc     string
	Tag     string
	TypeRef FieldTypeRef
	Fields  []*FieldSpec
}

func (*FieldSpec) String

func (fs *FieldSpec) String() string

type FieldTypeRef

type FieldTypeRef struct {
	Name string
	Pkg  string
	Kind FieldTypeRefKind
}

func (FieldTypeRef) IsBuiltIn added in v1.1.0

func (tr FieldTypeRef) IsBuiltIn() bool

func (FieldTypeRef) String

func (tr FieldTypeRef) String() string

type FieldTypeRefKind

type FieldTypeRefKind int
const (
	FieldTypeIdent FieldTypeRefKind = iota
	FieldTypeSelector
	FieldTypePtr
	FieldTypeArray
	FieldTypeMap
	FieldTypeStruct
)

func (*FieldTypeRefKind) ScanStr

func (r *FieldTypeRefKind) ScanStr(s string) bool

func (FieldTypeRefKind) String

func (i FieldTypeRefKind) String() string

type FileHandler

type FileHandler interface {
	// contains filtered or unexported methods
}

type FileSpec

type FileSpec struct {
	Name    string
	Pkg     string
	Imports []*ImportSpec
	Types   []*TypeSpec
	Export  bool // tru if file should be exported
}

func (*FileSpec) String

func (fs *FileSpec) String() string

type ImportHandler added in v1.6.0

type ImportHandler interface {
	// contains filtered or unexported methods
}

type ImportSpec added in v1.6.0

type ImportSpec struct {
	Name string // aka alias
	Path string
}

func (*ImportSpec) PathName added in v1.6.0

func (i *ImportSpec) PathName() string

type Parser added in v1.2.0

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

func NewParser added in v1.2.0

func NewParser(fileGlob, typeGlob string, opts ...ParserConfigOption) *Parser

func (*Parser) Parse added in v1.2.0

func (p *Parser) Parse(dir string) ([]*FileSpec, error)

type ParserConfigOption added in v1.2.0

type ParserConfigOption func(*Parser)

func WithDebug added in v1.2.0

func WithDebug(debug bool) ParserConfigOption

func WithExecConfig added in v1.2.0

func WithExecConfig(execFile string, execLine int) ParserConfigOption

type RootCollector

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

func NewRootCollector

func NewRootCollector(baseDir string, opts ...RootCollectorOption) *RootCollector

func (*RootCollector) Files

func (c *RootCollector) Files() []*FileSpec

type RootCollectorOption

type RootCollectorOption func(*RootCollector)

func WithFileGlob

func WithFileGlob(glob func(string) bool) RootCollectorOption

func WithGoGenDecl

func WithGoGenDecl(line int, file string) RootCollectorOption

func WithTypeGlob

func WithTypeGlob(glob func(string) bool) RootCollectorOption

type T

type T interface {
	Helper()
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

type TestTypeHandler

type TestTypeHandler interface {
	TypeHandler
	CommentHandler

	Types() []*TypeSpec
}

type TypeCollector

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

type TypeHandler

type TypeHandler interface {
	// contains filtered or unexported methods
}

type TypeSpec

type TypeSpec struct {
	Name   string
	Doc    string
	Fields []*FieldSpec
	Export bool // true if type should be exported
}

func (*TypeSpec) String

func (ts *TypeSpec) String() string

Jump to

Keyboard shortcuts

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