github.com/go-toolsmith/typep

Package typep provides type predicates.


Keywords
go, golang, predicates, types
License
MIT
Install
go get github.com/go-toolsmith/typep

Documentation

typep

build-img pkg-img reportcard-img version-img

Package typep provides type predicates.

Installation:

Go version 1.16+

go get github.com/go-toolsmith/typep

Example

package main

import (
	"fmt"

	"github.com/go-toolsmith/typep"
	"github.com/go-toolsmith/strparse"
)

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
}

License

MIT License.