typeutil

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncOf

func FuncOf(info *types.Info, call *ast.CallExpr) types.Object

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

Types

type FuncName

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

	// LocalFuncName is the package-local part (receiver and name).
	LocalFuncName
}

FuncName represents the fully qualified name of a function or method: Package path, receiver type, and function name, ignoring type parameters.

func FuncNameOf

func FuncNameOf(fun *types.Func) (name FuncName)

FuncNameOf 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) AppendText

func (f FuncName) AppendText(buf []byte) ([]byte, error)

AppendText implements encoding.TextAppender.

func (FuncName) Compare

func (f FuncName) Compare(other FuncName) int

Compare compares two FuncName instances lexicographically. It first compares by Path, and if they are equal, it compares by Receiver/Name.

func (FuncName) MarshalText

func (f FuncName) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (FuncName) String

func (f FuncName) String() string

String returns the fully qualified function name as a string.

The string representation uses parentheses around the receiver to avoid ambiguity: `(encoding/json.Decoder).Decode` for methods vs. `encoding/json.Unmarshal` for functions.

func (*FuncName) UnmarshalText

func (f *FuncName) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type LocalFuncName

type LocalFuncName struct {
	// Receiver is the name of the receiver type (e.g. "Decoder").
	// It is empty for regular functions.
	Receiver string

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

LocalFuncName is a package-local name of a function or method.

func (LocalFuncName) AppendText

func (l LocalFuncName) AppendText(buf []byte) ([]byte, error)

AppendText implements encoding.TextAppender.

func (LocalFuncName) Compare

func (l LocalFuncName) Compare(other LocalFuncName) int

Compare compares two LocalFuncName instances lexicographically by Receiver, then Name.

func (LocalFuncName) MarshalText

func (l LocalFuncName) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (LocalFuncName) String

func (l LocalFuncName) String() string

String returns the local function name as a string.

Since there is no package path, there is no ambiguity: the format is simply "Receiver.Name" for methods and "Name" for functions.

func (*LocalFuncName) UnmarshalText

func (l *LocalFuncName) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type RenameMap

type RenameMap map[LocalFuncName]map[string][]string

RenameMap is a map of local function names and identifiers to new identifier names.

Jump to

Keyboard shortcuts

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