Package typep provides type predicates.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
doc.go
example_test.go
go.mod
predicates.go
safeExpr.go
simplePredicates.go
simplePredicates_generate.go

README.md

Go Report Card GoDoc Build Status

typep

Package typep provides type predicates.

Installation:

go get -v 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
}