utils

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenUUID

func GenUUID() string

Return a 16-byte uuid

func GetErrorFromResponse

func GetErrorFromResponse(r *http.Response) error

Return the body from a response as an error

func GetJsonFromRequest

func GetJsonFromRequest(r *http.Request, v interface{}) error

Unmarshal JSON from request

func GetJsonFromResponse

func GetJsonFromResponse(r *http.Response, v interface{}) error

Unmarshal JSON from response

func GetStringFromResponse

func GetStringFromResponse(r *http.Response) (string, error)

Return the body from a response as a string

func SortedStringHas

func SortedStringHas(s sort.StringSlice, x string) bool

Check if a sorted string list has a string

func SortedStringsDelete

func SortedStringsDelete(s sort.StringSlice, x string) sort.StringSlice

Delete a string from a sorted string list

Types

type LogLevel

type LogLevel int
const (
	LEVEL_NOLOG LogLevel = iota
	LEVEL_CRITICAL
	LEVEL_ERROR
	LEVEL_WARNING
	LEVEL_INFO
	LEVEL_DEBUG
)

Log levels

type Logger

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

func NewLogger

func NewLogger(prefix string, level LogLevel) *Logger

Create a new logger

func (*Logger) Critical

func (l *Logger) Critical(format string, v ...interface{})

Log critical information

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Log string as debug

func (*Logger) Err

func (l *Logger) Err(err error) error

Log error variable

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Log string

func (*Logger) Level

func (l *Logger) Level() LogLevel

Return current level

func (*Logger) LogError

func (l *Logger) LogError(format string, v ...interface{}) error

Log error string

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

Set level

func (*Logger) WarnErr

func (l *Logger) WarnErr(err error) error

Log error variable as a warning

func (*Logger) Warning

func (l *Logger) Warning(format string, v ...interface{})

Log warning information

type StatusGroup

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

func NewStatusGroup

func NewStatusGroup() *StatusGroup

Create a new goroutine error status collector

func (*StatusGroup) Add

func (s *StatusGroup) Add(delta int)

Adds to the number of goroutines it should wait

func (*StatusGroup) Done

func (s *StatusGroup) Done()

Removes the number of pending goroutines by one

func (*StatusGroup) Err

func (s *StatusGroup) Err(err error)

Goroutine can return an error back to caller

func (*StatusGroup) Result

func (s *StatusGroup) Result() error

Returns an error if any of the spawned goroutines return an error. Only the last error is saved. This function must be called last after the last s.Register() function

type StringSet

type StringSet struct {
	Set sort.StringSlice
}

func NewStringSet

func NewStringSet() *StringSet

Create a string set.

A string set is a list where each element appears only once

func (*StringSet) Add

func (s *StringSet) Add(v string)

Add a string to the string set

func (*StringSet) Len

func (s *StringSet) Len() int

func (*StringSet) Strings

func (s *StringSet) Strings() []string

Return string list

type StringStack

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

func NewStringStack

func NewStringStack() *StringStack

func (*StringStack) IsEmpty

func (a *StringStack) IsEmpty() bool

func (*StringStack) Pop

func (a *StringStack) Pop() (x string)

func (*StringStack) Push

func (a *StringStack) Push(x string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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