https://github.com/stevenferrer/mira
This package wraps the reflect package and adds some useful methods for introspecting Go values
https://github.com/stevenferrer/mira
go golang reflect reflection
Last synced: 11 months ago
JSON representation
This package wraps the reflect package and adds some useful methods for introspecting Go values
- Host: GitHub
- URL: https://github.com/stevenferrer/mira
- Owner: stevenferrer
- License: mit
- Created: 2020-08-04T00:01:17.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2022-02-24T15:33:09.000Z (over 4 years ago)
- Last Synced: 2025-02-17T04:39:13.304Z (over 1 year ago)
- Topics: go, golang, reflect, reflection
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mira [](https://goreportcard.com/report/github.com/stevenferrer/mira)
This package wraps the `reflect` package and adds some useful methods for introspecting Go values.
## Installation
```console
$ go get github.com/stevenferrer/mira
```
## Usage
```go
import (
"fmt"
"github.com/stevenferrer/mira"
)
func main() {
v := int64(1)
typeInfo := mira.NewTypeInfo(v)
// check if value is numeric
if typeInfo.IsNumeric() {
fmt.Println("value is a numeric type")
}
// check if value is nillable
if typeInfo.IsNillable() {
fmt.Println("value is nillable")
}
// print type's name
fmt.Println(typeInfo.Name())
// print type's pkg path
fmt.Println(typeInfo.PkgPath())
// print the interface value
fmt.Printf("%v\n", typeInfo.V())
// print the reflect.Type's string representation
fmt.Printf("%v", typeInfo.T().String())
...
}
```
## License
MIT