gotypes

package module
v0.0.0-...-21a0139 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: MIT Imports: 2 Imported by: 5

README

gotypes

A bunch of wrappers for types to make it possible to pass them around.

Documentation

Index

Constants

View Source
const (
	Unknown   = Type(iota)
	Array     = Type(iota)
	Real      = Type(iota)
	Integer   = Type(iota)
	Boolean   = Type(iota)
	Text      = Type(iota)
	ValueType = Type(iota)
)

Types supported

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type int

Type is used to determine the underlying type at runtime

type Value

type Value interface {
	Type() Type
	Array() []Value
	Real() float64
	Integer() int64
	Bool() bool
	Text() string
	Unknown() interface{}
}

Value represents any type of value, this is used to pass around variadic sized arrays or values not known until runtime

func WrapArray

func WrapArray(value interface{}, theType Type) (result Value, err error)

WrapArray takes an array and returns an array of values

func WrapBoolean

func WrapBoolean(value bool) Value

WrapBoolean takes a boolean and returns a value

func WrapInteger

func WrapInteger(value int64) Value

WrapInteger takes an integer and returns a value

func WrapReal

func WrapReal(value float64) Value

WrapReal takes a real and returns a value

func WrapText

func WrapText(value string) Value

WrapText takes a string and returns a value

func WrapUnknown

func WrapUnknown(value interface{}) Value

WrapUnknown takes an interface and returns a value

Jump to

Keyboard shortcuts

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