types

package
v2.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorType = types.Universe.Lookup("error").Type()
	PanicType = types.Universe.Lookup("panic").Type()
	NilType   = types.Universe.Lookup("nil").Type()
)

Functions

func ContainsContext

func ContainsContext(t *types.Tuple) bool

func ContainsError

func ContainsError(results *types.Tuple) bool

func DetectBasePath

func DetectBasePath(pkg *packages.Package) (string, error)
func DetectAppPath(pkg *packages.Package) (string, error) {
	basePath, err := DetectBasePath(pkg)
	if err != nil {
		return "", err
	}

	srcPath := filepath.Join(build.Default.GOPATH, "src") + "/"
	index := strings.Index(basePath, srcPath)

	fmt.Println(basePath, srcPath, pkg.PkgPath)

	if index != -1 {
		return basePath[index+len(srcPath):], nil
	}
	return "", errors.New("fail detected app path")
}

func EvalBinaryExpr

func EvalBinaryExpr(expr *ast.BinaryExpr) (n, iotas int)

func EvalInt

func EvalInt(expr ast.Expr) (n, iotas int)

func GetBitSize

func GetBitSize(kind types.BasicKind) string

func HasNoEmptyValue

func HasNoEmptyValue(t types.Type) bool

func Inspect

func Inspect(pkgs []*packages.Package, f func(p *packages.Package, n ast.Node) bool)

func IsContext

func IsContext(t types.Type) bool

func IsError

func IsError(t types.Type) bool

func IsNamed

func IsNamed(t *types.Tuple) bool

func IsNil

func IsNil(t types.Type) bool

func IsPanic

func IsPanic(t types.Type) bool

func NameType

func NameType(vars []*types.Var, qf types.Qualifier, filterFn FilterFn) (results []string)

func NameTypeParams

func NameTypeParams(vars []*types.Var, qf types.Qualifier, filterFn FilterFn) (results []string)

func Params

func Params(vars []*types.Var, fn func(p *types.Var) []string, filterFn func(p *types.Var) bool) (results []string)

func ZeroValue

func ZeroValue(t types.Type, qf types.Qualifier) string

Types

type FilterFn

type FilterFn func(p *types.Var) bool

Jump to

Keyboard shortcuts

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