anyvalue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKindInfo

func NewKindInfo(a Any) kindInfo

Types

type Any

type Any = interface{}

Any represents a object that may contain any valid type.

type AnyValue

type AnyValue interface {

	// ValueOf returns a new Value initialized to the
	// concrete value stored in the interface i.
	// ValueOf(nil) returns the zero Value.
	ValueOf() reflect.Value

	// TypeOf returns the object's type.
	TypeOf() reflect.Type

	// Kind returns v's Kind. If v is the zero Value
	// (IsValid returns false), Kind returns Invalid.
	Kind() reflect.Kind

	// Interface returns the original underlying interface.
	Interface() Any

	// Indirect returns the value pointed to by a pointer.
	// If the AnyValue is not a pointer, indirect returns the
	// AnyValue unchanged.
	Indirect() AnyValue

	// Elem returns the value that the interface contains
	// or that the pointer points to. If the kind of the
	// AnyValue is not Interface or Ptr, the original
	// AnyValue is returned.
	Elem() reflect.Value

	String() string

	KindInfo
}

AnyValue is a wrapper around the Any interface, or interface{}, which may contain any value. The extra features of this wrapper allow value, type, and kind information, as well as whether the type is comparable, ordered, and/or iterable.

func NewAnyValue

func NewAnyValue(a Any) AnyValue

NewAnyValue returns a new AnyValue interface, e.g. v := NewAnyValue(uint(42))

AnyValue is a wrapper around the Any interface, or interface{}, which may contain any value. The original interface{} value is returned by v.Interface()

The extra features of this wrapper allow value, type, and kind information, as well as whether the type is comparable, ordered, and/or iterable.

type Kind

type Kind = reflect.Kind

A Kind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.

Reference: standard library reflect package

type Kind uint
const (
	Invalid Kind = iota
	Bool
	Int
	Int8
	Int16
	Int32
	Int64
	Uint
	Uint8
	Uint16
	Uint32
	Uint64
	Uintptr
	Float32
	Float64
	Complex64
	Complex128
	Array
	Chan
	Func
	Interface
	Map
	Ptr
	Slice
	String
	Struct
	UnsafePointer
)

type KindInfo

type KindInfo interface {
	IsComparable() bool
	IsOrdered() bool
	IsIterable() bool
	IsDeepComparable() bool
	HasAlternate() bool
}

Jump to

Keyboard shortcuts

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