gointerfacer

package module
v0.0.0-...-3fc9408 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2015 License: MIT Imports: 11 Imported by: 1

README

gointerfacer

Go interface helpers.

Based on https://github.com/josharian/impl

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindInterface

func FindInterface(iface string) (path string, pkg string, id string, err error)

FindInterface returns the import path and identifier of an interface. For example, given "http.ResponseWriter", FindInterface returns "net/http", "ResponseWriter".

Types

type Func

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

Func represents a function signature.

func Functions

func Functions(iface string) ([]Func, error)

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

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.

func TypeSpec

func TypeSpec(path string, id string) (Pkg, *ast.TypeSpec, error)

TypeSpec locates the *ast.TypeSpec for type id in the import path.

func (Pkg) FullType

func (p Pkg) FullType(e ast.Expr) string

FullType returns the fully qualified type of e. Examples, assuming package net/http:

FullType(int) => "int"
FullType(Handler) => "http.Handler"
FullType(io.Reader) => "io.Reader"
FullType(*Request) => "*http.Request"

func (Pkg) FuncSig

func (p Pkg) FuncSig(f *ast.Field) Func

func (Pkg) Params

func (p Pkg) Params(field *ast.Field) []Param

Jump to

Keyboard shortcuts

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