package treflect
Import Path
github.com/trivago/tgo/treflect (on go.dev)
Dependency Relation
imports 4 packages, and imported by one package
Package-Level Type Names (only one, which is exported)
TypeRegistry is a name to type registry used to create objects by name.
namedType map[string]reflect.Type
GetRegistered returns the names of all registered types for a given package
GetTypeOf returns only the type asscociated with the given name.
If the name is not registered, nil is returned.
The type returned will be a pointer type.
IsTypeRegistered returns true if a type is registered to this registry.
Note that GetTypeOf can do the same thing by checking for nil but also
returns the type, so in many cases you will want to call this function.
New creates an uninitialized object by class name.
The class name has to be "package.class" or "package/subpackage.class".
The gollum package is omitted from the package path.
Register a plugin to the TypeRegistry by passing an uninitialized object.
RegisterWithDepth to register a plugin to the TypeRegistry by passing an uninitialized object.
func NewTypeRegistry() TypeRegistry
Package-Level Functions (total 15, in which 14 are exported)
Clone does a deep copy of the given value.
Please note that field have to be public in order to be copied.
Private fields will be ignored.
Float32 converts any number type to an float32.
The second parameter is returned as false if a non-number type was given.
Float64 converts any number type to an float64.
The second parameter is returned as false if a non-number type was given.
GetMissingMethods checks if a given object implements all methods of a
given interface. It returns the interface coverage [0..1] as well as an array
of error messages. If the interface is correctly implemented the coverage is
1 and the error message array is empty.
Int64 converts any signed number type to an int64.
The second parameter is returned as false if a non-number type was given.
NewTypeRegistry creates a new TypeRegistry. Note that there is a global type
registry available in the main tgo package (tgo.TypeRegistry).
RemovePtrFromType will return the type of t and strips away any pointer(s)
in front of the actual type.
RemovePtrFromValue will return the value of t and strips away any pointer(s)
in front of the actual type.
SetMemberByIndex sets member idx of the given pointer-to-struct to the data
passed to this function. The member may be private, too.
SetMemberByName sets member name of the given pointer-to-struct to the data
passed to this function. The member may be private, too.
SetValue sets an addressable value to the data passed to this function.
In contrast to golangs reflect package this will also work with private
variables. Please note that this function may not support all types, yet.
Uint64 converts any unsigned number type to an uint64.
The second parameter is returned as false if a non-number type was given.
UnsafeCopy will copy data from src to dst while ignoring type information.
Both types need to be of the same size and dst and src have to be pointers.
UnsafeCopy will panic if these requirements are not met.
UnsafeCopyValue will copy data from src to dst while ignoring type
information. Both types need to be of the same size or this function will
panic. Also both types must support dereferencing via reflect.Elem()
The pages are generated with Golds v0.3.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |