utils

package
v0.0.0-...-7248963 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2014 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expect

func Expect(t *testing.T, expect string, actual interface{})

func ExpectNear

func ExpectNear(t *testing.T, expect float64, actual float64, acc float64)

func Filter

func Filter(in interface{}, fn filterf) interface{}

Filter(slice, predicate func) Usage:

d := Filter(b, func(val interface{}) bool {
  return val.(int) % 4 == 0
})

func Float64Filter

func Float64Filter(slice []float64, f filterFloat64) []float64

func IntFilter

func IntFilter(slice []int, f filterInt) []int

func IntSequence

func IntSequence(begin int) func() int

Return sequence integers with the begining value as x

func Map

func Map(in interface{}, fn mapf) interface{}

Map(slice, func)

Usages:

a := []int{1, 2, 3, 4}
b := Map(a, func(val interface{}) interface{} {
	 return val.(int) * 2
})

should be [2, 4, 6, 8]

func Reduce

func Reduce(in interface{}, memo interface{}, fn reducef) interface{}

Reduce(slice, starting value, func)

Usage:

c := Reduce(b, 0, func(val interface{}, memo interface{}) interface{} {
  return memo.(int) + val.(int)
})

Types

type Dictionary

type Dictionary struct {
	// contains filtered or unexported fields
}

func NewDictionary

func NewDictionary(minId int) *Dictionary

func (*Dictionary) AddName

func (d *Dictionary) AddName(name string) int

func (*Dictionary) GetIdFromName

func (d *Dictionary) GetIdFromName(name string) int

func (*Dictionary) GetNameFromId

func (d *Dictionary) GetNameFromId(id int) string

type Logger

type Logger struct {
	LogLevel string
	Facility string
	// contains filtered or unexported fields
}

func Init

func Init(facility string, priority string, name string) *Logger

func (*Logger) Close

func (log *Logger) Close()

func (*Logger) Log

func (log *Logger) Log(priority string, m string) error

Jump to

Keyboard shortcuts

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