typeutil

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllDecls

func AllDecls[T ast.Decl](files []*ast.File) iter.Seq[T]

AllDecls iterates over all declarations of the specified type T in the given files.

func FuncOf

func FuncOf(info *types.Info, ex ast.Expr) (fun *types.Func, methodExpr, ok bool)

FuncOf iteratively unwraps an expression to find the underlying function declaration.

Types

type FuncName

type FuncName struct {
	// Path is the package path ("encoding/json").
	Path string

	// Receiver is the name of the receiver type ("Decoder").
	// It is empty for regular functions.
	Receiver string

	// Name is the function or method name ("Decode").
	Name string

	// Ptr is true if the receiver is a pointer type.
	Ptr bool
}

FuncName represents the fully qualified name of a function or method. It deconstructs a function's identity into its constituent parts: package path, receiver type, function name and ignores type parameters.

func NewFuncName

func NewFuncName(fun *types.Func) FuncName

NewFuncName extracts the name components of a given *types.Func. It populates a FuncName struct, which is simplified and canonicalized from fun.Fullname() and can then be used as a map index or to get a string representation.

func (FuncName) String

func (f FuncName) String() string

String returns the fully qualified function name as a string. For a method, the format is "(*<path>.<receiver>).<name>". For a function, the format is "<path>.<name>".

Jump to

Keyboard shortcuts

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