util

package
v0.0.0-...-02c4206 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2013 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DynMapConvertable

func DynMapConvertable(value interface{}) bool

Returns true if the given value is a map, dynmap, DynMaper or pointer of one of those types

func ToBool

func ToBool(value interface{}) (bool, error)

func ToInt

func ToInt(value interface{}) (int, error)

func ToInt64

func ToInt64(value interface{}) (i int64, err error)

func ToMap

func ToMap(value interface{}) (map[string]interface{}, bool)

attempts to convert the given value to a map. returns

func ToString

func ToString(value interface{}) string

func ToTime

func ToTime(value interface{}) (tm time.Time, err error)

parse time

Types

type Config

type Config struct {
	DynMap
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(filePath string) *Config

func (*Config) Load

func (this *Config) Load()

type DynMap

type DynMap struct {
	Map map[string]interface{}
}

Dont make this a map type, since we want the option of extending this and adding members.

func New

func New() *DynMap

Creates a new dynmap

func NewDynMap

func NewDynMap() *DynMap

Deprecated. use New() instead

func ToDynMap

func ToDynMap(value interface{}) (*DynMap, bool)

func (*DynMap) AddToSlice

func (this *DynMap) AddToSlice(key string, mp interface{}) error

Adds the item to a slice

func (*DynMap) Exists

func (this *DynMap) Exists(key string) bool

func (*DynMap) Get

func (this *DynMap) Get(key string) (interface{}, bool)

Get's the value. will honor the dot operator if needed. key = 'map.map2' will first attempt to matche the literal key 'map.map2' if no value is present it will look for a sub map at key 'map'

func (*DynMap) GetBool

func (this *DynMap) GetBool(key string) (bool, bool)

func (*DynMap) GetDynMap

func (this *DynMap) GetDynMap(key string) (*DynMap, bool)

Gets a dynmap from the requested. This will update the value in the map if the value was not already a dynmap.

func (*DynMap) GetDynMapSlice

func (this *DynMap) GetDynMapSlice(key string) ([]*DynMap, bool)

gets a slice of dynmaps

func (*DynMap) GetInt

func (this *DynMap) GetInt(key string) (int, bool)

func (*DynMap) GetInt64

func (this *DynMap) GetInt64(key string) (int64, bool)

Gets the value at the specified key as an int64. returns -1,false if value not available or is not convertable

func (*DynMap) GetIntSlice

func (this *DynMap) GetIntSlice(key string) ([]int, bool)

Returns a slice of ints

func (*DynMap) GetIntSliceSplit

func (this *DynMap) GetIntSliceSplit(key, delim string) ([]int, bool)

gets a slice of ints. if the value is a string it will split by the requested delimiter

func (*DynMap) GetString

func (this *DynMap) GetString(key string) (string, bool)

Gets a string representation of the value at key

func (*DynMap) GetStringSlice

func (this *DynMap) GetStringSlice(key string) ([]string, bool)

Returns a slice of strings

func (*DynMap) GetStringSliceSplit

func (this *DynMap) GetStringSliceSplit(key, delim string) ([]string, bool)

gets a slice of strings. if the value is a string it will split by the requested delimiter

func (*DynMap) GetTime

func (this *DynMap) GetTime(key string) (time.Time, bool)

func (*DynMap) MarshalJSON

func (this *DynMap) MarshalJSON() ([]byte, error)

func (*DynMap) MarshalURL

func (this *DynMap) MarshalURL() (string, error)

encodes this map into a url encoded string. maps are encoded in the rails style (key[key2][key2]=value) TODO: we should sort the keynames so ordering is consistent and then this can be used a cache key

func (*DynMap) MustBool

func (this *DynMap) MustBool(key string, def bool) bool

func (*DynMap) MustDynMap

func (this *DynMap) MustDynMap(key string, def *DynMap) *DynMap

func (*DynMap) MustInt

func (this *DynMap) MustInt(key string, def int) int

func (*DynMap) MustInt64

func (this *DynMap) MustInt64(key string, def int64) int64

func (*DynMap) MustString

func (this *DynMap) MustString(key string, def string) string

gets a string. if string is not available in the map, then the default is returned

func (*DynMap) MustTime

func (this *DynMap) MustTime(key string, def time.Time) time.Time

func (*DynMap) Put

func (this *DynMap) Put(key string, value interface{})

Put's a value into the map

func (*DynMap) PutAll

func (this *DynMap) PutAll(mp interface{}) bool

puts all the values from the passed in map into this dynmap the passed in map must be convertable to a DynMap via ToDynMap. returns false if the passed value is not convertable to dynmap

func (*DynMap) PutIfAbsent

func (this *DynMap) PutIfAbsent(key string, value interface{}) (interface{}, bool)

Puts the value into the map if and only if no value exists at the specified key. This does not honor the dot operator on insert.

func (*DynMap) PutIfAbsentWithDot

func (this *DynMap) PutIfAbsentWithDot(key string, value interface{}) (interface{}, bool)

Same as PutIfAbsent but honors the dot operator

func (*DynMap) PutWithDot

func (this *DynMap) PutWithDot(key string, value interface{}) error

puts the value into the map, honoring the dot operator. so PutWithDot("map1.map2.value", 100) would result in:

{
  map1 : { map2 : { value: 100 }}

}

func (*DynMap) Remove

func (this *DynMap) Remove(key string) (interface{}, bool)

Remove a mapping TODO: this will need to honor the dot operator!

func (*DynMap) ToDynMap

func (this *DynMap) ToDynMap() *DynMap

Returns self. Here so that we satisfy the DynMaper interface

func (*DynMap) ToMap

func (this *DynMap) ToMap() map[string]interface{}

Recursively converts this to a regular go map. (will convert any sub maps)

func (*DynMap) UnmarshalJSON

func (this *DynMap) UnmarshalJSON(bytes []byte) error

func (*DynMap) UnmarshalURL

func (this *DynMap) UnmarshalURL(urlstring string) error

Unmarshals a url encoded string. will also parse rails style maps in the form key[key1][key2]=val

func (*DynMap) UnmarshalURLValues

func (this *DynMap) UnmarshalURLValues(values url.Values) error

Unmarshals url.Values into the map. Will correctly handle rails style maps in the form key[key1][key2]=val

type DynMaper

type DynMaper interface {
	ToDynMap() *DynMap
}

type Log

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

func NewLog

func NewLog() *Log

func (*Log) Access

func (l *Log) Access(r *http.Request)

func (*Log) AddLog

func (l *Log) AddLog(key string, path string)

func (*Log) Close

func (l *Log) Close(key string)

func (*Log) CloseAll

func (l *Log) CloseAll()

func (*Log) Error

func (l *Log) Error(r *http.Request)

func (*Log) Log

func (l *Log) Log(key string, message string)

type Logger

type Logger interface {
	Log()
}

Jump to

Keyboard shortcuts

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