common

package
v0.0.0-...-56027fb Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReflectTypeError = reflect.TypeOf((*error)(nil)).Elem()
)

Functions

func AnyToBytes

func AnyToBytes(v any) []byte

AnyToBytes converts value to byte slice

func AnyToString

func AnyToString(v any) string

AnyToString converts value to string

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note: it may break if string and/or slice header will change in the future go versions.

func New

func New(t Type) any

func ParseReflectValue

func ParseReflectValue(s string, t reflect.Type) (reflect.Value, error)

func ReflectValueToString

func ReflectValueToString(v reflect.Value) string

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without memory allocation.

Note: it may break if string and/or slice header will change in the future go versions.

Types

type Closer

type Closer interface {
	Close() error
}

type Key

type Key interface {
	fmt.Stringer

	Value() string
}

func NewKey

func NewKey(v string) Key

type Type

type Type int
const (
	Bool Type = iota
	Integer
	Unsigned
	Float
	String
	Binary
	Timestamp
)

func TypeOf

func TypeOf(v any) Type

TypeOf gets the Type of v. Only part of Types are supported.

func TypeOfReflectType

func TypeOfReflectType(t reflect.Type) Type

TypeOfReflectType returns the Type of reflect.Type t.

func (Type) String

func (t Type) String() string

type Value

type Value interface {
	fmt.Stringer

	Value() any
}

func NewValue

func NewValue(v any) Value

type Void

type Void interface{}

func NewVoid

func NewVoid() Void

Jump to

Keyboard shortcuts

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