rtutil

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 3 Imported by: 2

README

go-rtutil

Go runtime / reflect utilities (hacks). You should not use these without deep understanding! (that's probably a bold claim about my own undstanding...)

So yeah, here be dragons and all that.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRuntimeType added in v1.2.0

func GetRuntimeType(t reflect.Type) unsafe.Pointer

GetRuntimeType will fetch a pointer for the runtime._type value of the originating object this reflect.Type represents. This is possible because the reflect package returns the value of an interface{}'s Eface.Type cast as their copy of runtime._type. So the Eface.Data value for this reflected type will be the underlying runtime type this was from.

func GetStructFields

func GetStructFields(v interface{}) []reflect.StructField

GetStructFields will fetch struct field information for any struct-type 'v', caching the results between consecutive calls. For this reason you should treat returned fields as READ-ONLY. This method is useful if you expect to be regularly reflecting and iterating a type's struct fields.

func GetStructFieldsByType added in v1.1.0

func GetStructFieldsByType(t reflect.Type) []reflect.StructField

GetStructFieldsByType will fetch struct field information for any reflected struct-type 't', caching the results between consecutive calls. For this reason you should treat returned fields as READ-ONLY. This method is useful if you expect to be regularly reflecting and iterating a type's struct fields.

func IsValidStructTag

func IsValidStructTag(tag string) bool

IsValidStructTag will return whether tag value is valid for use, i.e. not empty or marked as ignore '-'.

Types

type Eface

type Eface struct {
	// Type is a pointer to the runtime._type.
	Type unsafe.Pointer

	// Value is a pointer to the actual data.
	Value unsafe.Pointer
}

Eface (empty interface) is the header for an interface{} value.

func ToEface

func ToEface(v interface{}) *Eface

ToEface will return the Eface header for given interface{} value.

Jump to

Keyboard shortcuts

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