types

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallableImportPaths

func CallableImportPaths(ref string) []string

CallableImportPaths returns every possible package portion of a function or method reference.

func TypeExprImportPaths

func TypeExprImportPaths(input string) ([]string, error)

TypeExprImportPaths returns every possible import path referenced by a supported type expression. Resolution tries the same candidates later, after they have been loaded together.

Types

type Function

type Function struct {
	Ref        string
	ImportPath string
	Name       string
	Func       *types.Func
	Signature  *types.Signature
}

Function is a loaded package-level Go function referenced by a Tego option.

type Loader

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

Loader is a simplified, caching Go type loader that is built to load the symbols required by Tego for things like tegopb.GoType's type ref, and to and from proto callables.

func NewLoader

func NewLoader(opts ...LoaderOption) *Loader

NewLoader returns a new Loader instance.

func (*Loader) Function

func (l *Loader) Function(ref string) (*Function, error)

Function attempts to load the function with the given ref, returning a Function instance if successful.

func (*Loader) Method

func (l *Loader) Method(ref string) (*Method, error)

Method attempts to load the method with the given ref, returning a Method instance if successful.

func (*Loader) PackageNames

func (l *Loader) PackageNames() map[string]string

PackageNames returns the declared package name for every package currently cached by the loader.

func (*Loader) Preload

func (l *Loader) Preload(importPaths []string) error

Preload loads importPaths together so that all of their dependencies share one go/types universe. Packages with loading errors are left out of the cache so that resolving one of their symbols later still returns the usual focused error.

func (*Loader) Type

func (l *Loader) Type(ref string) (*Type, error)

Type attempts to load the type with the given ref, returning a Type instance if successful.

func (*Loader) TypeExpr

func (l *Loader) TypeExpr(ref string, typeArgs map[string]string) (*TypeExpr, error)

TypeExpr resolves a Go type expression using Tego's supported subset: named and predeclared types, type parameters, pointers, slices, arrays, maps, and generic instantiations.

type LoaderOption

type LoaderOption func(*Loader)

LoaderOption allows this Loader to be customized during construction.

func WithDir

func WithDir(dir string) LoaderOption

WithDir sets the directory packages are loaded from.

func WithPackagesConfig

func WithPackagesConfig(config *packages.Config) LoaderOption

WithPackagesConfig allows custom packages.Config to be specified.

type Method

type Method struct {
	Ref        string
	ImportPath string
	Receiver   string
	Name       string
	Func       *types.Func
	Signature  *types.Signature
}

Method is a loaded Go method referenced by a Tego option.

type Type

type Type struct {
	Ref        string
	ImportPath string
	Name       string
	TypeName   *types.TypeName
	Type       types.Type
	Named      *types.Named
}

Type is a loaded named Go type referenced by a Tego option.

type TypeExpr

type TypeExpr struct {
	Ref        string
	Kind       TypeExprKind
	ImportPath string
	Name       string
	TypeName   *types.TypeName
	Type       types.Type
	Named      *types.Named
	Args       []TypeExpr
	Elem       *TypeExpr
	Key        *TypeExpr
	Value      *TypeExpr
	Length     int64
}

TypeExpr is a parsed and loaded Go type expression used by custom go_type options.

type TypeExprKind

type TypeExprKind uint

TypeExprKind enumerates the possible outer forms of a parsed Go type expression.

const (
	// TypeExprKindNamed is a named Go type, possibly with type arguments.
	TypeExprKindNamed TypeExprKind = iota
	// TypeExprKindPointer is a pointer type expression.
	TypeExprKindPointer
	// TypeExprKindSlice is a slice type expression.
	TypeExprKindSlice
	// TypeExprKindPredeclared is a predeclared Go value type.
	TypeExprKindPredeclared
	// TypeExprKindArray is a fixed-length array type expression.
	TypeExprKindArray
	// TypeExprKindMap is a map type expression.
	TypeExprKindMap
)

Jump to

Keyboard shortcuts

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