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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 RPCID

func RPCID() int64

RPCID retrieves the next RPC ID.

func RequestID

func RequestID() int64

RequestID retrieves the next Request ID.

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.

func ValidateLatLng

func ValidateLatLng(lat, lng float64) bool

ValidateLatLng validates a lat/lng pair against the Continental US boundaries.

Types

type Address

type Address struct {
	Addr      string
	City      string
	State     string
	Zip       string
	Lat, Long float64
	Valid     bool
}

Address represents a standard US street address.

func AddrForLatLng

func AddrForLatLng(lat, lng float64) (a Address, err error)

AddrForLatLng finds the nearest address to the coordinates.

func NewAddr

func NewAddr(fullAddr string, looseZip bool) (addr Address, err error)

NewAddr returns a new address struct from a full, comma delimited street address.

func NewAddrP

func NewAddrP(addr1, city, state, zip string, looseZip bool) (addr Address, err error)

NewAddrP returns a new address struct from the address, city, state, and option zipcode.

func ParseAddress

func ParseAddress(fullAddr string, looseZip bool) (a Address, err error)

ParseAddress accepts a comma delimited address string, and returns the address, city, state and zip. NOTE: this function does very little error checking.

func (*Address) FullAddr

func (r *Address) FullAddr() string

FullAddr returns the standard comma delimited full addres string, like: "{{addr}}, {{city}}, {{state}} {{zip}}"

func (Address) String

func (r Address) String() string

String displays the contents of the CreateRequest type.

func (*Address) Validate

func (r *Address) Validate(addr, zip bool) bool

Validate does simple range checking to make sure all address fields are populated. If zip is false, then the zipcode will not be included in the validation.

type Conversion

type Conversion struct {
	Validation
}

Conversion represents a Conversion. It is composed of a Validation.

func NewConversion

func NewConversion() Conversion

NewConversion returns a conversion set. A Conversion set will log all errors captured during one or more conversions. All possible conversions are specifed below in init().

func (*Conversion) Bool

func (r *Conversion) Bool(name, val string) bool

Bool validates a boolean target as per the vparms for the specified name.

func (*Conversion) Float

func (r *Conversion) Float(name, val string) float64

Float validates a float target as per the vparms for the specified name.

func (*Conversion) Int

func (r *Conversion) Int(name, val string) int

Int validates a integer target as per the vparms for the specified name.

func (Conversion) String

func (r Conversion) String() string

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

ColorBool returns a colored string depending on whether the specified value is true or false.

type SerialID

type SerialID int64

SerialID creates a serial ID type (int64).

func (*SerialID) Get

func (r *SerialID) Get() int64

Get retrieves the next Serial ID

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.

type Validation

type Validation map[string]*ValidationDetail

Validation is a simple method for compiling validation results.

func NewValidation

func NewValidation() Validation

NewValidation returns a Validation type.

func (Validation) Error

func (r Validation) Error() string

Error is a standard error interface, returning a string listing any failed validations.

func (Validation) IsOK

func (r Validation) IsOK(item string) bool

IsOK returns the state of the requested Validation. If the Validation has not been set, it will return FALSE.

func (Validation) Ok

func (r Validation) Ok() bool

Ok scans all validations - if all are true (i.e. they passed that validation test), then it returns true.

func (Validation) Set

func (r Validation) Set(item, result string, isOK bool)

Set creates a validation as ok (true) or not (false).

func (Validation) String

func (r Validation) String() string

String returns a string representation of the validation entries.

type ValidationDetail

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

ValidationDetail is a simple method for compiling validation results.

Jump to

Keyboard shortcuts

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