Documentation ¶
Overview ¶
Package typep provides type predicates.
Example ¶
package main import ( "fmt" "go/types" "github.com/go-toolsmith/typep" ) func main() { 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 ¶
- func HasBoolKind(typ types.Type) bool
- func HasBooleanProp(typ types.Type) bool
- func HasComplex128Kind(typ types.Type) bool
- func HasComplex64Kind(typ types.Type) bool
- func HasComplexProp(typ types.Type) bool
- func HasConstTypeProp(typ types.Type) bool
- func HasFloat32Kind(typ types.Type) bool
- func HasFloat64Kind(typ types.Type) bool
- func HasFloatProp(typ types.Type) bool
- func HasInt16Kind(typ types.Type) bool
- func HasInt32Kind(typ types.Type) bool
- func HasInt64Kind(typ types.Type) bool
- func HasInt8Kind(typ types.Type) bool
- func HasIntKind(typ types.Type) bool
- func HasIntegerProp(typ types.Type) bool
- func HasNumericProp(typ types.Type) bool
- func HasOrderedProp(typ types.Type) bool
- func HasStringKind(typ types.Type) bool
- func HasStringProp(typ types.Type) bool
- func HasUint16Kind(typ types.Type) bool
- func HasUint32Kind(typ types.Type) bool
- func HasUint64Kind(typ types.Type) bool
- func HasUint8Kind(typ types.Type) bool
- func HasUintKind(typ types.Type) bool
- func HasUintptrKind(typ types.Type) bool
- func HasUnsafePointerKind(typ types.Type) bool
- func HasUnsignedProp(typ types.Type) bool
- func HasUntypedBoolKind(typ types.Type) bool
- func HasUntypedComplexKind(typ types.Type) bool
- func HasUntypedFloatKind(typ types.Type) bool
- func HasUntypedIntKind(typ types.Type) bool
- func HasUntypedNilKind(typ types.Type) bool
- func HasUntypedProp(typ types.Type) bool
- func HasUntypedRuneKind(typ types.Type) bool
- func HasUntypedStringKind(typ types.Type) bool
- func IsArray(typ types.Type) bool
- func IsBasic(typ types.Type) bool
- func IsChan(typ types.Type) bool
- func IsInterface(typ types.Type) bool
- func IsMap(typ types.Type) bool
- func IsNamed(typ types.Type) bool
- func IsPointer(typ types.Type) bool
- func IsSignature(typ types.Type) bool
- func IsSlice(typ types.Type) bool
- func IsStruct(typ types.Type) bool
- func IsTuple(typ types.Type) bool
- func IsTypeExpr(info *types.Info, x ast.Expr) bool
- func SideEffectFree(info *types.Info, expr ast.Expr) bool
- func SideEffectFreeList(info *types.Info, list []ast.Expr) bool
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasBoolKind ¶
HasBoolKind reports whether typ is a *types.Basic with its kind set to types.Bool.
func HasBooleanProp ¶
HasBooleanProp reports whether typ is a *types.Basic has IsBoolean property.
func HasComplex128Kind ¶
HasComplex128Kind reports whether typ is a *types.Basic with its kind set to types.Complex128.
func HasComplex64Kind ¶
HasComplex64Kind reports whether typ is a *types.Basic with its kind set to types.Complex64.
func HasComplexProp ¶
HasComplexProp reports whether typ is a *types.Basic has IsComplex property.
func HasConstTypeProp ¶
HasConstTypeProp reports whether typ is a *types.Basic has IsConstType property.
func HasFloat32Kind ¶
HasFloat32Kind reports whether typ is a *types.Basic with its kind set to types.Float32.
func HasFloat64Kind ¶
HasFloat64Kind reports whether typ is a *types.Basic with its kind set to types.Float64.
func HasFloatProp ¶
HasFloatProp reports whether typ is a *types.Basic has IsFloat property.
func HasInt16Kind ¶
HasInt16Kind reports whether typ is a *types.Basic with its kind set to types.Int16.
func HasInt32Kind ¶
HasInt32Kind reports whether typ is a *types.Basic with its kind set to types.Int32.
func HasInt64Kind ¶
HasInt64Kind reports whether typ is a *types.Basic with its kind set to types.Int64.
func HasInt8Kind ¶
HasInt8Kind reports whether typ is a *types.Basic with its kind set to types.Int8.
func HasIntKind ¶
HasIntKind reports whether typ is a *types.Basic with its kind set to types.Int.
func HasIntegerProp ¶
HasIntegerProp reports whether typ is a *types.Basic has IsInteger property.
func HasNumericProp ¶
HasNumericProp reports whether typ is a *types.Basic has IsNumeric property.
func HasOrderedProp ¶
HasOrderedProp reports whether typ is a *types.Basic has IsOrdered property.
func HasStringKind ¶
HasStringKind reports whether typ is a *types.Basic with its kind set to types.String.
func HasStringProp ¶
HasStringProp reports whether typ is a *types.Basic has IsString property.
func HasUint16Kind ¶
HasUint16Kind reports whether typ is a *types.Basic with its kind set to types.Uint16.
func HasUint32Kind ¶
HasUint32Kind reports whether typ is a *types.Basic with its kind set to types.Uint32.
func HasUint64Kind ¶
HasUint64Kind reports whether typ is a *types.Basic with its kind set to types.Uint64.
func HasUint8Kind ¶
HasUint8Kind reports whether typ is a *types.Basic with its kind set to types.Uint8.
func HasUintKind ¶
HasUintKind reports whether typ is a *types.Basic with its kind set to types.Uint.
func HasUintptrKind ¶
HasUintptrKind reports whether typ is a *types.Basic with its kind set to types.Uintptr.
func HasUnsafePointerKind ¶
HasUnsafePointerKind reports whether typ is a *types.Basic with its kind set to types.UnsafePointer.
func HasUnsignedProp ¶
HasUnsignedProp reports whether typ is a *types.Basic has IsUnsigned property.
func HasUntypedBoolKind ¶
HasUntypedBoolKind reports whether typ is a *types.Basic with its kind set to types.UntypedBool.
func HasUntypedComplexKind ¶
HasUntypedComplexKind reports whether typ is a *types.Basic with its kind set to types.UntypedComplex.
func HasUntypedFloatKind ¶
HasUntypedFloatKind reports whether typ is a *types.Basic with its kind set to types.UntypedFloat.
func HasUntypedIntKind ¶
HasUntypedIntKind reports whether typ is a *types.Basic with its kind set to types.UntypedInt.
func HasUntypedNilKind ¶
HasUntypedNilKind reports whether typ is a *types.Basic with its kind set to types.UntypedNil.
func HasUntypedProp ¶
HasUntypedProp reports whether typ is a *types.Basic has IsUntyped property.
func HasUntypedRuneKind ¶
HasUntypedRuneKind reports whether typ is a *types.Basic with its kind set to types.UntypedRune.
func HasUntypedStringKind ¶
HasUntypedStringKind reports whether typ is a *types.Basic with its kind set to types.UntypedString.
func IsInterface ¶
IsInterface reports whether a given type has *types.Interface type.
func IsSignature ¶
IsSignature reports whether a given type has *types.Signature type.
func IsTypeExpr ¶
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 ¶
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.
Types ¶
This section is empty.