reflectkit

package
v0.235.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseType added in v0.181.0

func BaseType(typ reflect.Type) (_ reflect.Type, depth int)

func BaseTypeOf

func BaseTypeOf(i any) reflect.Type

func BaseValue

func BaseValue(v reflect.Value) reflect.Value

func BaseValueOf

func BaseValueOf(i any) reflect.Value

func Cast

func Cast[T any](v any) (T, bool)

func Equal

func Equal(x, y any) bool

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

func FullyQualifiedName(e any) string
Example
package main

import (
	"fmt"

	"go.llib.dev/frameless/pkg/reflectkit"
)

func main() {
	fmt.Println(reflectkit.FullyQualifiedName(Example{}))
}

type Example struct {
	Name string
}

func IsEmpty added in v0.207.0

func IsEmpty(val reflect.Value) bool

func IsValueNil

func IsValueNil(val reflect.Value) bool

func IsZero added in v0.217.0

func IsZero(val reflect.Value) bool
func Link(src, ptr any) (err error)

Link will make destination interface be linked with the src value.

func PointerOf added in v0.181.0

func PointerOf(value reflect.Value) reflect.Value

func RegisterEqual

func RegisterEqual[T any](fn func(x, y T) bool) struct{}

func SetValue

func SetValue(variable, value reflect.Value)

SetValue will force set

func SymbolicName

func SymbolicName(e any) string
Example
package main

import (
	"fmt"

	"go.llib.dev/frameless/pkg/reflectkit"
)

func main() {
	fmt.Println(reflectkit.SymbolicName(Example{}))
}

type Example struct {
	Name string
}

func TypeOf added in v0.180.0

func TypeOf[T any](i ...T) reflect.Type

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL