Documentation
¶
Index ¶
- Constants
- func BaseTypeOf(i any) reflect.Type
- func BaseValue(v reflect.Value) reflect.Value
- func BaseValueOf(i any) reflect.Value
- func Cast[T any](v any) (T, bool)
- func DerefType(T reflect.Type) (_ reflect.Type, depth int)
- func Equal(x, y any) bool
- func FullyQualifiedName(v any) string
- func IsEmpty(val reflect.Value) bool
- func IsNil(val reflect.Value) bool
- func IsZero(val reflect.Value) bool
- func Link(src, ptr any) (err error)
- func LookupField[FieldID StructFieldID](rStruct reflect.Value, i FieldID) (reflect.StructField, reflect.Value, bool)
- func PointerOf(value reflect.Value) reflect.Value
- func RegisterEqual[T any](fn func(x, y T) bool) struct{}
- func SetValue(variable, value reflect.Value)
- func SymbolicName(v any) string
- func ToSettable(rv reflect.Value) (_ reflect.Value, ok bool)
- func ToValue(v any) reflect.Value
- func TypeOf[T any](i ...T) reflect.Type
- type StructFieldID
Examples ¶
Constants ¶
View Source
const ErrTypeMismatch errorkit.Error = "ErrTypeMismatch"
Variables ¶
This section is empty.
Functions ¶
func BaseTypeOf ¶
func BaseValueOf ¶
func Equal ¶
Equal will compare two value deeply. It looks for Equal method on the value as well. You can define how a type's value should be compared by using RegisterEqual.
Example ¶
package main import ( "go.llib.dev/frameless/pkg/reflectkit" ) func main() { reflectkit.Equal("a", "a") // true reflectkit.Equal("a", "b") // false }
func FullyQualifiedName ¶
Example ¶
package main import ( "fmt" "go.llib.dev/frameless/pkg/reflectkit" ) func main() { fmt.Println(reflectkit.FullyQualifiedName(Example{})) } type Example struct { Name string }
func Link ¶
Link will make destination interface be linked with the src value.
Example ¶
package main import ( "go.llib.dev/frameless/pkg/reflectkit" ) func main() { var src = Example{Name: "Panda"} var dest Example if err := reflectkit.Link(src, &dest); err != nil { // handle err } } type Example struct { Name string }
func LookupField ¶ added in v0.278.0
func LookupField[FieldID StructFieldID](rStruct reflect.Value, i FieldID) (reflect.StructField, reflect.Value, bool)
func RegisterEqual ¶
func SymbolicName ¶
Example ¶
package main import ( "fmt" "go.llib.dev/frameless/pkg/reflectkit" ) func main() { fmt.Println(reflectkit.SymbolicName(Example{})) } type Example struct { Name string }
func ToSettable ¶ added in v0.278.0
Example ¶
package main import ( "reflect" "go.llib.dev/frameless/pkg/reflectkit" ) func main() { type T struct{ v int } var v T ptr := reflect.ValueOf(&v) rStruct := ptr.Elem() got, ok := reflectkit.ToSettable(rStruct.FieldByName("v")) _, _ = got, ok }
Types ¶
type StructFieldID ¶ added in v0.278.0
type StructFieldID interface { reflect.StructField | int | string }
Click to show internal directories.
Click to hide internal directories.