Documentation ¶
Index ¶
- func Tail(buffer *bytes.Buffer, n int) string
- type Decoder
- type Env
- func (env *Env) Decode(src io.Reader) error
- func (env *Env) Encode(dst io.Writer) error
- func (env *Env) Exists(key string) bool
- func (env *Env) Get(key string) (value string)
- func (env *Env) GetBool(key string) (value bool)
- func (env *Env) GetInt(key string) int
- func (env *Env) GetInt64(key string) int64
- func (env *Env) GetJson(key string, iface interface{}) error
- func (env *Env) GetList(key string) []string
- func (env *Env) GetSubEnv(key string) *Env
- func (env *Env) GetTime(key string) (time.Time, error)
- func (env *Env) Import(src interface{}) (err error)
- func (env *Env) Init(src *Env)
- func (env *Env) InitMultiMap(m map[string][]string)
- func (env *Env) Len() int
- func (env *Env) Map() map[string]string
- func (env *Env) MultiMap() map[string][]string
- func (env *Env) Set(key, value string)
- func (env *Env) SetAuto(k string, v interface{})
- func (env *Env) SetBool(key string, value bool)
- func (env *Env) SetInt(key string, value int)
- func (env *Env) SetInt64(key string, value int64)
- func (env *Env) SetJson(key string, value interface{}) error
- func (env *Env) SetList(key string, value []string) error
- func (env *Env) SetSubEnv(key string, sub *Env) error
- func (env *Env) SetTime(key string, t time.Time)
- func (env *Env) WriteJSON(w http.ResponseWriter, code int) error
- func (env *Env) WriteTo(dst io.Writer) (int64, error)
- type Input
- type Output
- func (o *Output) Add(dst io.Writer)
- func (o *Output) AddEnv() (dst *Env, err error)
- func (o *Output) AddListTable() (dst *Table, err error)
- func (o *Output) AddPipe() (io.Reader, error)
- func (o *Output) AddTable() (dst *Table, err error)
- func (o *Output) Close() error
- func (o *Output) Set(dst io.Writer)
- func (o *Output) Used() bool
- func (o *Output) Write(p []byte) (n int, err error)
- type Table
- func (t *Table) Add(env *Env)
- func (t *Table) Len() int
- func (t *Table) Less(a, b int) bool
- func (t *Table) ReadFrom(src io.Reader) (n int64, err error)
- func (t *Table) ReadListFrom(src []byte) (n int64, err error)
- func (t *Table) ReverseSort()
- func (t *Table) SetKey(sortKey string)
- func (t *Table) Sort()
- func (t *Table) Swap(a, b int)
- func (t *Table) ToListString() (string, error)
- func (t *Table) WriteListTo(dst io.Writer) (n int64, err error)
- func (t *Table) WriteTo(dst io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
func NewDecoder ¶
type Env ¶
type Env []string
func (*Env) Decode ¶
DecodeEnv decodes `src` as a json dictionary, and adds each decoded key-value pair to the environment.
If `src` cannot be decoded as a json dictionary, an error is returned.
func (*Env) Get ¶
Get returns the last value associated with the given key. If there are no values associated with the key, Get returns the empty string.
func (*Env) InitMultiMap ¶
InitMultiMap removes all values in env, then initializes new values from the contents of m.
func (*Env) Len ¶
Len returns the number of keys in the environment. Note that len(env) might be different from env.Len(), because the same key might be set multiple times.
func (*Env) MultiMap ¶
MultiMap returns a representation of env as a map of string arrays, keyed by string. This is the same structure as http headers for example, which allow each key to have multiple values.
type Input ¶
func NewInput ¶
func NewInput() *Input
NewInput returns a new Input object with no source attached. Reading to an empty Input will return io.EOF.
type Output ¶
func NewOutput ¶
func NewOutput() *Output
NewOutput returns a new Output object with no destinations attached. Writing to an empty Output will cause the written data to be discarded.
func (*Output) Add ¶
Add attaches a new destination to the Output. Any data subsequently written to the output will be written to the new destination in addition to all the others. This method is thread-safe.
func (*Output) AddEnv ¶
AddEnv starts a new goroutine which will decode all subsequent data as a stream of json-encoded objects, and point `dst` to the last decoded object. The result `env` can be queried using the type-neutral Env interface. It is not safe to query `env` until the Output is closed.
func (*Output) AddListTable ¶
func (*Output) AddPipe ¶
AddPipe creates an in-memory pipe with io.Pipe(), adds its writing end as a destination, and returns its reading end for consumption by the caller. This is a rough equivalent similar to Cmd.StdoutPipe() in the standard os/exec package. This method is thread-safe.
func (*Output) Close ¶
Close unregisters all destinations and waits for all background AddTail and AddString tasks to complete. The Close method of each destination is called if it exists.
func (*Output) Set ¶
Set closes and remove existing destination and then attaches a new destination to the Output. Any data subsequently written to the output will be written to the new destination in addition to all the others. This method is thread-safe.