typep: github.com/go-toolsmith/typep Index | Examples | Files

package typep

import "github.com/go-toolsmith/typep"

Package typep provides type predicates.

Code:

floatTyp := types.Typ[types.Float32]
intTyp := types.Typ[types.Int]
ptr := types.NewPointer(intTyp)
arr := types.NewArray(intTyp, 64)
fmt.Println(typep.HasFloatProp(floatTyp)) // => true
fmt.Println(typep.HasFloatProp(intTyp))   // => false
fmt.Println(typep.IsPointer(ptr))         // => true
fmt.Println(typep.IsArray(arr))           // => true

Output:

true
false
true
true

Index

Examples

Package Files

doc.go predicates.go safeExpr.go simplePredicates.go

func HasBoolKind Uses

func HasBoolKind(typ types.Type) bool

HasBoolKind reports whether typ is a *types.Basic with its kind set to types.Bool.

func HasBooleanProp Uses

func HasBooleanProp(typ types.Type) bool

HasBooleanProp reports whether typ is a *types.Basic has IsBoolean property.

func HasComplex128Kind Uses

func HasComplex128Kind(typ types.Type) bool

HasComplex128Kind reports whether typ is a *types.Basic with its kind set to types.Complex128.

func HasComplex64Kind Uses

func HasComplex64Kind(typ types.Type) bool

HasComplex64Kind reports whether typ is a *types.Basic with its kind set to types.Complex64.

func HasComplexProp Uses

func HasComplexProp(typ types.Type) bool

HasComplexProp reports whether typ is a *types.Basic has IsComplex property.

func HasConstTypeProp Uses

func HasConstTypeProp(typ types.Type) bool

HasConstTypeProp reports whether typ is a *types.Basic has IsConstType property.

func HasFloat32Kind Uses

func HasFloat32Kind(typ types.Type) bool

HasFloat32Kind reports whether typ is a *types.Basic with its kind set to types.Float32.

func HasFloat64Kind Uses

func HasFloat64Kind(typ types.Type) bool

HasFloat64Kind reports whether typ is a *types.Basic with its kind set to types.Float64.

func HasFloatProp Uses

func HasFloatProp(typ types.Type) bool

HasFloatProp reports whether typ is a *types.Basic has IsFloat property.

func HasInt16Kind Uses

func HasInt16Kind(typ types.Type) bool

HasInt16Kind reports whether typ is a *types.Basic with its kind set to types.Int16.

func HasInt32Kind Uses

func HasInt32Kind(typ types.Type) bool

HasInt32Kind reports whether typ is a *types.Basic with its kind set to types.Int32.

func HasInt64Kind Uses

func HasInt64Kind(typ types.Type) bool

HasInt64Kind reports whether typ is a *types.Basic with its kind set to types.Int64.

func HasInt8Kind Uses

func HasInt8Kind(typ types.Type) bool

HasInt8Kind reports whether typ is a *types.Basic with its kind set to types.Int8.

func HasIntKind Uses

func HasIntKind(typ types.Type) bool

HasIntKind reports whether typ is a *types.Basic with its kind set to types.Int.

func HasIntegerProp Uses

func HasIntegerProp(typ types.Type) bool

HasIntegerProp reports whether typ is a *types.Basic has IsInteger property.

func HasNumericProp Uses

func HasNumericProp(typ types.Type) bool

HasNumericProp reports whether typ is a *types.Basic has IsNumeric property.

func HasOrderedProp Uses

func HasOrderedProp(typ types.Type) bool

HasOrderedProp reports whether typ is a *types.Basic has IsOrdered property.

func HasStringKind Uses

func HasStringKind(typ types.Type) bool

HasStringKind reports whether typ is a *types.Basic with its kind set to types.String.

func HasStringProp Uses

func HasStringProp(typ types.Type) bool

HasStringProp reports whether typ is a *types.Basic has IsString property.

func HasUint16Kind Uses

func HasUint16Kind(typ types.Type) bool

HasUint16Kind reports whether typ is a *types.Basic with its kind set to types.Uint16.

func HasUint32Kind Uses

func HasUint32Kind(typ types.Type) bool

HasUint32Kind reports whether typ is a *types.Basic with its kind set to types.Uint32.

func HasUint64Kind Uses

func HasUint64Kind(typ types.Type) bool

HasUint64Kind reports whether typ is a *types.Basic with its kind set to types.Uint64.

func HasUint8Kind Uses

func HasUint8Kind(typ types.Type) bool

HasUint8Kind reports whether typ is a *types.Basic with its kind set to types.Uint8.

func HasUintKind Uses

func HasUintKind(typ types.Type) bool

HasUintKind reports whether typ is a *types.Basic with its kind set to types.Uint.

func HasUintptrKind Uses

func HasUintptrKind(typ types.Type) bool

HasUintptrKind reports whether typ is a *types.Basic with its kind set to types.Uintptr.

func HasUnsafePointerKind Uses

func HasUnsafePointerKind(typ types.Type) bool

HasUnsafePointerKind reports whether typ is a *types.Basic with its kind set to types.UnsafePointer.

func HasUnsignedProp Uses

func HasUnsignedProp(typ types.Type) bool

HasUnsignedProp reports whether typ is a *types.Basic has IsUnsigned property.

func HasUntypedBoolKind Uses

func HasUntypedBoolKind(typ types.Type) bool

HasUntypedBoolKind reports whether typ is a *types.Basic with its kind set to types.UntypedBool.

func HasUntypedComplexKind Uses

func HasUntypedComplexKind(typ types.Type) bool

HasUntypedComplexKind reports whether typ is a *types.Basic with its kind set to types.UntypedComplex.

func HasUntypedFloatKind Uses

func HasUntypedFloatKind(typ types.Type) bool

HasUntypedFloatKind reports whether typ is a *types.Basic with its kind set to types.UntypedFloat.

func HasUntypedIntKind Uses

func HasUntypedIntKind(typ types.Type) bool

HasUntypedIntKind reports whether typ is a *types.Basic with its kind set to types.UntypedInt.

func HasUntypedNilKind Uses

func HasUntypedNilKind(typ types.Type) bool

HasUntypedNilKind reports whether typ is a *types.Basic with its kind set to types.UntypedNil.

func HasUntypedProp Uses

func HasUntypedProp(typ types.Type) bool

HasUntypedProp reports whether typ is a *types.Basic has IsUntyped property.

func HasUntypedRuneKind Uses

func HasUntypedRuneKind(typ types.Type) bool

HasUntypedRuneKind reports whether typ is a *types.Basic with its kind set to types.UntypedRune.

func HasUntypedStringKind Uses

func HasUntypedStringKind(typ types.Type) bool

HasUntypedStringKind reports whether typ is a *types.Basic with its kind set to types.UntypedString.

func IsArray Uses

func IsArray(typ types.Type) bool

IsArray reports whether a given type has *types.Array type.

func IsBasic Uses

func IsBasic(typ types.Type) bool

IsBasic reports whether a given type has *types.Basic type.

func IsChan Uses

func IsChan(typ types.Type) bool

IsChan reports whether a given type has *types.Chan type.

func IsInterface Uses

func IsInterface(typ types.Type) bool

IsInterface reports whether a given type has *types.Interface type.

func IsMap Uses

func IsMap(typ types.Type) bool

IsMap reports whether a given type has *types.Map type.

func IsNamed Uses

func IsNamed(typ types.Type) bool

IsNamed reports whether a given type has *types.Named type.

func IsPointer Uses

func IsPointer(typ types.Type) bool

IsPointer reports whether a given type has *types.Pointer type.

func IsSignature Uses

func IsSignature(typ types.Type) bool

IsSignature reports whether a given type has *types.Signature type.

func IsSlice Uses

func IsSlice(typ types.Type) bool

IsSlice reports whether a given type has *types.Slice type.

func IsStruct Uses

func IsStruct(typ types.Type) bool

IsStruct reports whether a given type has *types.Struct type.

func IsTuple Uses

func IsTuple(typ types.Type) bool

IsTuple reports whether a given type has *types.Tuple type.

func IsTypeExpr Uses

func IsTypeExpr(info *types.Info, x ast.Expr) bool

IsTypeExpr reports whether x represents a type expression.

Type expression does not evaluate to any run time value, but rather describes a type that is used inside Go expression.

For example, (*T)(v) is a CallExpr that "calls" (*T). (*T) is a type expression that tells Go compiler type v should be converted to.

func SideEffectFree Uses

func SideEffectFree(info *types.Info, expr ast.Expr) bool

SideEffectFree reports whether expr is softly safe expression and contains no significant side-effects. As opposed to strictly safe expressions, soft safe expressions permit some forms of side-effects, like panic possibility during indexing or nil pointer dereference.

Uses types info to determine type conversion expressions that are the only permitted kinds of call expressions. Note that is does not check whether called function really has any side effects. The analysis is very conservative.

func SideEffectFreeList Uses

func SideEffectFreeList(info *types.Info, list []ast.Expr) bool

SideEffectFreeList reports whether every expr in list is safe.

See SideEffectFree.

Package typep imports 3 packages (graph) and is imported by 5 packages. Updated 2019-01-17. Refresh now. Tools for package owners.