genutil

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package genutil is a utility package for query helpers codegeneration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Implementations

func Implementations(pkg *packages.Package, iface *types.Interface) []*types.Named

Implementations finds iface implementations.

func Load

func Load(ctx context.Context, pattern string) (*packages.Package, error)

Load loads package using given pattern.

func PrintType

func PrintType(typ types.Type) string

PrintType prints typename into string without package name.

func WriteTemplate

func WriteTemplate(source fs.FS, out io.Writer, name string, data interface{}) error

WriteTemplate loads template from FS and executes it to given output writer.

Types

type Func

type Func struct {
	Sig  *types.Signature
	Decl *types.Func
}

Func is a function representation.

func Funcs

func Funcs(pkg *packages.Package, keep func(f Func) bool) []Func

Funcs collects all function from package using given filter. Parameter keep may be nil.

func (Func) Args

func (f Func) Args() *types.Tuple

Args returns function arguments.

func (Func) Results

func (f Func) Results() *types.Tuple

Results returns function results.

type Interfaces

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

Interfaces is a simple utility struct to find interfaces and implementations.

func NewInterfaces

func NewInterfaces(pkg *packages.Package) *Interfaces

NewInterfaces creates new Interfaces structure.

func (*Interfaces) Implementations

func (c *Interfaces) Implementations(name string) ([]*types.Named, error)

Implementations finds interface implementations by interface name.

func (*Interfaces) Interface

func (c *Interfaces) Interface(name string) (*types.Interface, error)

Interface finds interface by name.

Jump to

Keyboard shortcuts

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