https://github.com/pumpkinseed/reflection
Golang reflection helper
https://github.com/pumpkinseed/reflection
golang-library reflection
Last synced: 6 months ago
JSON representation
Golang reflection helper
- Host: GitHub
- URL: https://github.com/pumpkinseed/reflection
- Owner: PumpkinSeed
- Created: 2019-10-28T12:17:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-31T14:34:52.000Z (almost 6 years ago)
- Last Synced: 2025-04-14T13:16:07.661Z (6 months ago)
- Topics: golang-library, reflection
- Language: Go
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reflection
The package try to solve the type issues when reflect.Set happens.
#### Usage
```go
package mainimport (
"reflect""github.com/PumpkinSeed/reflection"
"github.com/volatiletech/null"
)type Example struct {
Integer int
String string
Nullable null.Uint
StringPtr *string
}func main() {
var example = &Example{}
err := reflection.Set(reflect.ValueOf(example.Integer), "12")
// err check
err = reflection.Set(reflect.ValueOf(example.String), 12)
// err check
err = reflection.Set(reflect.ValueOf(example.Nullable), 12)
// err check
err = reflection.Set(reflect.ValueOf(example.StringPtr), "12")
// err check
}
```