models

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

type Expression struct {
	Value      string
	IsStar     bool
	IsVariadic bool
	IsWriter   bool
	Underlying string
}

Expression represents a type expression in Go code, including metadata about pointers, variadic parameters, and writers.

func (*Expression) String

func (e *Expression) String() string

String returns the string representation of the expression, including pointer and variadic prefixes.

type Field

type Field struct {
	Name  string
	Type  *Expression
	Index int
}

Field represents a parameter, result, or struct field in a function or method signature.

func (*Field) IsBasicType

func (f *Field) IsBasicType() bool

IsBasicType returns true if the field is a Go basic type (bool, string, int, etc.).

func (*Field) IsNamed

func (f *Field) IsNamed() bool

IsNamed returns true if the field has a non-blank name.

func (*Field) IsStruct

func (f *Field) IsStruct() bool

IsStruct returns true if the field's underlying type is a struct.

func (*Field) IsWriter

func (f *Field) IsWriter() bool

IsWriter returns true if the field is an io.Writer.

func (*Field) ShortName

func (f *Field) ShortName() string

ShortName returns a short single-letter name based on the field's type.

type Function

type Function struct {
	Name         string
	IsExported   bool
	Receiver     *Receiver
	Parameters   []*Field
	Results      []*Field
	ReturnsError bool
	TypeParams   []*TypeParam // Type parameters for generic functions
	Body         string       // Source code of the function body for AI context
}

Function represents a function or method signature with its parameters, results, and metadata.

func (*Function) FullName

func (f *Function) FullName() string

FullName returns the full name of the function, including the receiver type if it's a method.

func (*Function) IsNaked

func (f *Function) IsNaked() bool

IsNaked returns true if the function has no receiver, parameters, or results.

func (*Function) OnlyReturnsError

func (f *Function) OnlyReturnsError() bool

OnlyReturnsError returns true if the function returns only an error.

func (*Function) OnlyReturnsOneValue

func (f *Function) OnlyReturnsOneValue() bool

OnlyReturnsOneValue returns true if the function returns exactly one non-error value.

func (*Function) ReturnsMultiple

func (f *Function) ReturnsMultiple() bool

ReturnsMultiple returns true if the function returns more than one value.

func (*Function) TestName

func (f *Function) TestName() string

TestName returns the name to use for the generated test function.

func (*Function) TestParameters

func (f *Function) TestParameters() []*Field

TestParameters returns the function's parameters excluding io.Writer parameters.

func (*Function) TestResults

func (f *Function) TestResults() []*Field

TestResults returns the function's results plus any io.Writer parameters converted to string results.

type Header struct {
	Comments []string
	Package  string
	Imports  []*Import
	Code     []byte
}

Header represents the header of a Go file, including package name, imports, and any code between imports and declarations.

type Import

type Import struct {
	Name, Path string
}

Import represents an import statement with an optional name and the import path.

type Path

type Path string

Path represents a file system path.

func (Path) IsTestPath

func (p Path) IsTestPath() bool

IsTestPath returns true if the path is a test file path (ends with _test.go).

func (Path) TestPath

func (p Path) TestPath() string

TestPath returns the test file path for the given source file path.

type Receiver

type Receiver struct {
	*Field
	Fields []*Field
}

Receiver represents a method receiver, including its type and struct fields.

type TypeParam added in v1.8.0

type TypeParam struct {
	Name       string // e.g., "T", "K", "V"
	Constraint string // e.g., "any", "comparable", "int64 | float64"
}

TypeParam represents a type parameter in a generic function or type.

Jump to

Keyboard shortcuts

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