asciigoat's core library
https://asciigoat.org/core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
452 B
27 lines
452 B
package reflective |
|
|
|
import "reflect" |
|
|
|
// Reflection provides Marshalling/Unmarshalling oriented view |
|
// of a value |
|
type Reflection struct { |
|
v reflect.Value |
|
} |
|
|
|
// New creates a Reflection of the given pointer |
|
func New(v any) (*Reflection, error) { |
|
rv := reflect.ValueOf(v) |
|
|
|
if rv.Kind() != reflect.Pointer || rv.IsNil() { |
|
err := &InvalidUnmarshalError{ |
|
Type: rv.Type(), |
|
} |
|
return nil, err |
|
} |
|
|
|
r := &Reflection{ |
|
v: rv, |
|
} |
|
|
|
return r, nil |
|
}
|
|
|