impler

package
v0.0.0-...-225f367 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 15 Imported by: 0

README

impler is implemented based on project impl, and most of the code is copied from it directly.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenImplStubs

func GenImplStubs(recv string, fns []Func, implemented map[string]bool) []byte

GenImplStubs prints nicely formatted method stubs for fns using receiver expression recv. If recv is not a valid receiver expression, genImplStubs will panic. genImplStubs won't generate stubs for already implemented methods of receiver.

func GenInterfaceStubs

func GenInterfaceStubs(ifaceName string, fns []Func) []byte

GenInterfaceStubs generates interface stub code.

func GetReceiverType

func GetReceiverType(recv string) string

GetReceiverType returns type name of receiver or fatal if receiver is invalid. ex: for definition "r *SomeType" will return "SomeType"

func ImplementedFuncs

func ImplementedFuncs(fns []Func, recv string, srcDir string) (map[string]bool, error)

ImplementedFuncs returns list of Func which already implemented.

func NewCommand

func NewCommand() *cli.Command

NewCommand creates an impler command

Types

type Func

type Func struct {
	Name     string
	Params   []Param
	Res      []Param
	Comments string
}

Func represents a function signature.

func Funcs

func Funcs(iface string, srcDir string) ([]Func, error)

Funcs returns the set of methods required to implement iface. It is called Funcs rather than methods because the function descriptions are functions; there is no receiver.

func Methods

func Methods(structure string, srcDir string) ([]Func, error)

Methods returns the set of structure's methods.

type Method

type Method struct {
	Recv string
	Func
}

Method represents a method signature.

type Param

type Param struct {
	Name string
	Type string
}

Param represents a parameter in a function or method signature.

type Pkg

type Pkg struct {
	*build.Package
	*token.FileSet
}

Pkg is a parsed build.Package.

type Spec

type Spec struct {
	*ast.TypeSpec
	ast.CommentMap
}

Spec is ast.TypeSpec with the associated comment map.

Jump to

Keyboard shortcuts

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