common

package
v0.0.0-...-58575ba Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpClientTimeout = time.Duration(5 * time.Second)
)

Variables

This section is empty.

Functions

func BoxIt

func BoxIt(str []string, width int) string

BoxIt creates a box around the input string with the specified width.

func ByteToString

func ByteToString(input []byte, length int) string

ByteToString converts a byte array to a string.

func ProgramElapsedTime

func ProgramElapsedTime() float64

ProgramElapsedTime returns the time elapsed since the program started.

func Round

func Round(num float64) int

Round returns an int of the rounded value of the float input.

func SetPrecision

func SetPrecision(num float64, precision int) float64

SetPrecision effectively rounds a floating point number to the specified precision.

func TimeoutChan

func TimeoutChan(t time.Duration) chan bool

TimeoutChan returns a "chan bool" that will receive a "true" value after the specifed dur`ation t.

Types

type JSONConfig

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

JSONConfig provides functionality to read a JSON config file into the parent struct.

func (*JSONConfig) Read

func (r *JSONConfig) Read(parent interface{}, filePath string) error

Read loads the config file into the parent struct.

type LogString

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

LogString is used to "box" object representations.

func NewLogString

func NewLogString() *LogString

NewLogString creates a new LogString, and initializes color printing.

func (*LogString) AddF

func (l *LogString) AddF(format string, args ...interface{})

AddF adds a formated line of text, like Printf().

func (*LogString) AddS

func (l *LogString) AddS(s string)

AddS adds a single line of text, with no terminating line return.

func (*LogString) AddSR

func (l *LogString) AddSR(s string)

AddSR adds a single line of text (with line return), like Println().

func (*LogString) Box

func (l *LogString) Box(w int) string

Box draws a box around the LogString with the specified line width, with a leading line return.

func (*LogString) BoxC

func (l *LogString) BoxC(w int) string

BoxC draws a box around the LogString with the specified line width, without a leading line return.

func (*LogString) Color

func (l *LogString) Color(s, color string) string

Color applies the specified color to the string.

func (*LogString) ColorBool

func (l *LogString) ColorBool(v bool, strue, sfalse, ctrue, cfalse string) string

Color applies the specified color to the string.

type UnixTimestampType

type UnixTimestampType int64

UnixTimestampType reqresents a Unix timestamp.

func (*UnixTimestampType) SetCurrentTime

func (r *UnixTimestampType) SetCurrentTime()

SetCurrentTime sets the UnixTimestampType variable to the current time.

func (UnixTimestampType) String

func (r UnixTimestampType) String() string

String returns a string represenation of a UnixTimestampType custom type.

Jump to

Keyboard shortcuts

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