Involved Source Filesswapper.go
Package reflectlite implements lightweight version of reflect, not using
any package except for "runtime" and "unsafe".
value.goasm.s
Package-Level Type Names (total 26, in which 4 are exported)
Type is the representation of a Go type.
Not all methods apply to all kinds of types. Restrictions,
if any, are noted in the documentation for each method.
Use the Kind method to find out the kind of type before
calling kind-specific methods. Calling a method
inappropriate to the kind of type causes a run-time panic.
Type values are comparable, such as with the == operator,
so they can be used as map keys.
Two Type values are equal if they represent identical types.
AssignableTo reports whether a value of the type is assignable to type u.
Comparable reports whether values of this type are comparable.
Elem returns a type's element type.
It panics if the type's Kind is not Ptr.
Implements reports whether the type implements the interface type u.
Kind returns the specific kind of this type.
Name returns the type's name within its package for a defined type.
For other (non-defined) types it returns the empty string.
PkgPath returns a defined type's package path, that is, the import path
that uniquely identifies the package, such as "encoding/base64".
If the type was predeclared (string, error) or not defined (*T, struct{},
[]int, or A where A is an alias for a non-defined type), the package path
will be the empty string.
Size returns the number of bytes needed to store
a value of the given type; it is analogous to unsafe.Sizeof.
String returns a string representation of the type.
The string representation may use shortened package names
(e.g., base64 instead of "encoding/base64") and is not
guaranteed to be unique among types. To test for type identity,
compare the Types directly.
( T) common() *rtype( T) uncommon() *uncommonType
*arrayType
*chanType
*funcType
*interfaceType
*mapType
*ptrType
*rtype
*sliceType
*structType
*structTypeUncommon
T : fmt.Stringer
T : github.com/neo4j/neo4j-go-driver/v4/neo4j.DatabaseInfo
T : context.stringer
T : runtime.stringer
func TypeOf(i interface{}) Type
func Type.Elem() Type
func Value.Type() Type
func toType(t *rtype) Type
func Type.AssignableTo(u Type) bool
func Type.Implements(u Type) bool
func haveIdenticalType(T, V Type, cmpTags bool) bool
var errors.errorType
Value is the reflection interface to a Go value.
Not all methods apply to all kinds of values. Restrictions,
if any, are noted in the documentation for each method.
Use the Kind method to find out the kind of value before
calling kind-specific methods. Calling a method
inappropriate to the kind of type causes a run time panic.
The zero Value represents no value.
Its IsValid method returns false, its Kind method returns Invalid,
its String method returns "<invalid Value>", and all other methods panic.
Most functions and methods never return an invalid value.
If one does, its documentation states the conditions explicitly.
A Value can be used concurrently by multiple goroutines provided that
the underlying Go value can be used concurrently for the equivalent
direct operations.
To compare two Values, compare the results of the Interface method.
Using == on two Values does not compare the underlying values
they represent.
flag holds metadata about the value.
The lowest bits are flag bits:
- flagStickyRO: obtained via unexported not embedded field, so read-only
- flagEmbedRO: obtained via unexported embedded field, so read-only
- flagIndir: val holds a pointer to the data
- flagAddr: v.CanAddr is true (implies flagIndir)
Value cannot represent method values.
The next five bits give the Kind of the value.
This repeats typ.Kind() except for method values.
The remaining 23+ bits give a method number for method values.
If flag.kind() != Func, code can assume that flagMethod is unset.
If ifaceIndir(typ), code can assume that flagIndir is set.
Pointer-valued data or, if flagIndir is set, pointer to data.
Valid when either flagIndir is set or typ.pointers() is true.
typ holds the type of the value represented by a Value.
CanSet reports whether the value of v can be changed.
A Value can be changed only if it is addressable and was not
obtained by the use of unexported struct fields.
If CanSet returns false, calling Set or any type-specific
setter (e.g., SetBool, SetInt) will panic.
Elem returns the value that the interface v contains
or that the pointer v points to.
It panics if v's Kind is not Interface or Ptr.
It returns the zero Value if v is nil.
IsNil reports whether its argument v is nil. The argument must be
a chan, func, interface, map, pointer, or slice value; if it is
not, IsNil panics. Note that IsNil is not always equivalent to a
regular comparison with nil in Go. For example, if v was created
by calling ValueOf with an uninitialized interface variable i,
i==nil will be true but v.IsNil will panic as v will be the zero
Value.
IsValid reports whether v represents a value.
It returns false if v is the zero Value.
If IsValid returns false, all other methods except String panic.
Most functions and methods never return an invalid Value.
If one does, its documentation states the conditions explicitly.
Kind returns v's Kind.
If v is the zero Value (IsValid returns false), Kind returns Invalid.
Len returns v's length.
It panics if v's Kind is not Array, Chan, Map, Slice, or String.
Set assigns x to the value v.
It panics if CanSet returns false.
As in Go, x's value must be assignable to v's type.
Type returns v's type.
assignTo returns a value v that can be assigned directly to typ.
It panics if v is not assignable to typ.
For a conversion to an interface type, target is a suggested scratch space to use.
( T) kind() Kind
mustBeAssignable panics if f records that the value is not assignable,
which is to say that either it was obtained using an unexported field
or it is not addressable.
mustBeExported panics if f records that the value was obtained using
an unexported field.
NumMethod returns the number of exported methods in the value's method set.
pointer returns the underlying pointer represented by v.
v.Kind() must be Ptr, Map, Chan, Func, or UnsafePointer
( T) ro() flag
func ValueOf(i interface{}) Value
func Value.Elem() Value
func unpackEface(i interface{}) Value
func Value.assignTo(context string, dst *rtype, target unsafe.Pointer) Value
func Value.Set(x Value)
func packEface(v Value) interface{}
func valueInterface(v Value) interface{}
A ValueError occurs when a Value method is invoked on
a Value that does not support it. Such cases are documented
in the description of each method.
KindKindMethodstring(*T) Error() string
*T : error
( T) kind() Kind
mustBeAssignable panics if f records that the value is not assignable,
which is to say that either it was obtained using an unexported field
or it is not addressable.
mustBeExported panics if f records that the value was obtained using
an unexported field.
( T) ro() flag
const flagAddr
const flagEmbedRO
const flagIndir
const flagKindMask
const flagMethod
const flagRO
const flagStickyRO
Method on non-interface type
// fn used in interface call (one-word receiver)
// method type (without receiver)
// name of method
// fn used for normal method call
name is an encoded type name with optional extra data.
The first byte is a bit field containing:
1<<0 the name is exported
1<<1 tag data follows the name
1<<2 pkgPath nameOff follows the name and tag
The next two bytes are the data length:
l := uint16(data[1])<<8 | uint16(data[2])
Bytes [3:3+l] are the string data.
If tag data follows then bytes 3+l and 3+l+1 are the tag length,
with the data following.
If the import path follows, then 4 bytes at the end of
the data form a nameOff. The import path is only set for concrete
methods that are defined in a different package than their type.
If a name starts with "*", then the exported bit represents
whether the pointed to type is exported.
bytes*byte( T) data(off int, whySafe string) *byte( T) isExported() bool( T) name() (s string)( T) nameLen() int( T) pkgPath() string( T) tag() (s string)( T) tagLen() int
tflag is used by an rtype to signal what extra type information is
available in the memory directly following the rtype value.
tflag values must be kept in sync with copies in:
cmd/compile/internal/gc/reflect.go
cmd/link/internal/ld/decodesym.go
runtime/type.go
const tflagExtraStar
const tflagNamed
const tflagRegularMemory
const tflagUncommon
uncommonType is present only for defined types or types with methods
(if T is a defined type, the uncommonTypes for T and *T have methods).
Using a pointer to this struct reduces the overall size required
to describe a non-defined type with no methods.
// number of methods
// offset from this uncommontype to [mcount]method
// import path; empty for built-in types like int, string
// number of exported methods
(*T) exportedMethods() []method(*T) methods() []method
Package-Level Functions (total 23, in which 3 are exported)
Swapper returns a function that swaps the elements in the provided
slice.
Swapper panics if the provided interface is not a slice.
TypeOf returns the reflection Type that represents the dynamic type of i.
If i is a nil interface value, TypeOf returns nil.
ValueOf returns a new Value initialized to the concrete value
stored in the interface i. ValueOf(nil) returns the zero Value.
add returns p+x.
The whySafe string is ignored, so that the function still inlines
as efficiently as p+x, but all call sites should use the string to
record why the addition is safe, which is to say why the addition
does not cause x to advance to the very end of p's allocation
and therefore point incorrectly at the next block in memory.
arrayAt returns the i-th element of p,
an array whose elements are eltSize bytes wide.
The array pointed at by p must have at least i+1 elements:
it is invalid (but impossible to check here) to pass i >= len,
because then the result will point outside the array.
whySafe must explain why i < len. (Passing "i < len" is fine;
the benefit is to surface this assumption at the call site.)
implemented in runtime:
directlyAssignable reports whether a value x of type V can be directly
assigned (using memmove) to a value of type T.
https://golang.org/doc/go_spec.html#Assignability
Ignoring the interface rules (implemented elsewhere)
and the ideal constant rules (no ideal constants at run time).
Dummy annotation marking that the value x escapes,
for use in cases where the reflect code is so clever that
the compiler cannot follow.
methodName returns the name of the calling method,
assumed to be two stack frames above.
packEface converts v to the empty interface.
resolveNameOff resolves a name offset from a base pointer.
The (*rtype).nameOff method is a convenience wrapper for this function.
Implemented in the runtime package.
resolveTypeOff resolves an *rtype offset from a base type.
The (*rtype).typeOff method is a convenience wrapper for this function.
Implemented in the runtime package.
toType converts from a *rtype to a Type that can be returned
to the client of package reflect. In gc, the only concern is that
a nil *rtype must be replaced by a nil Type, but in gccgo this
function takes care of ensuring that multiple *rtype for the same
type are coalesced into a single Type.
typedmemmove copies a value of type t to dst from src.
unpackEface converts the empty interface i to a Value.
tflagExtraStar means the name in the str field has an
extraneous '*' prefix. This is because for most types T in
a program, the type *T also exists and reusing the str data
saves binary size.
tflagNamed means the type has a name.
tflagRegularMemory means that equal and hash functions can treat
this type as a single region of t.size bytes.
tflagUncommon means that there is a pointer, *uncommonType,
just beyond the outer type structure.
For example, if t.Kind() == Struct and t.tflag&tflagUncommon != 0,
then t has uncommonType data and it can be accessed as:
type tUncommon struct {
structType
u uncommonType
}
u := &(*tUncommon)(unsafe.Pointer(t)).u
The pages are generated with Goldsv0.4.2. (GOOS=darwin 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.