https://github.com/go-toolsmith/typep
Package typep provides type predicates.
https://github.com/go-toolsmith/typep
go golang predicates types
Last synced: 5 months ago
JSON representation
Package typep provides type predicates.
- Host: GitHub
- URL: https://github.com/go-toolsmith/typep
- Owner: go-toolsmith
- License: mit
- Created: 2018-10-29T08:12:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T07:31:43.000Z (over 2 years ago)
- Last Synced: 2024-06-18T23:07:33.710Z (about 2 years ago)
- Topics: go, golang, predicates, types
- Language: Go
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typep
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![version-img]][version-url]
Package `typep` provides type predicates.
## Installation:
Go version 1.16+
```bash
go get github.com/go-toolsmith/typep
```
## Example
```go
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](LICENSE).
[build-img]: https://github.com/go-toolsmith/typep/workflows/build/badge.svg
[build-url]: https://github.com/go-toolsmith/typep/actions
[pkg-img]: https://pkg.go.dev/badge/go-toolsmith/typep
[pkg-url]: https://pkg.go.dev/github.com/go-toolsmith/typep
[reportcard-img]: https://goreportcard.com/badge/go-toolsmith/typep
[reportcard-url]: https://goreportcard.com/report/go-toolsmith/typep
[version-img]: https://img.shields.io/github/v/release/go-toolsmith/typep
[version-url]: https://github.com/go-toolsmith/typep/releases