utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

View Source
const GLOB = "*"

GLOB is the character which is treaded like a glob

Variables

This section is empty.

Functions

func GetHost

func GetHost(uri string) (string, error)

GetHost obtains the host value from a url or domain

func GetHostname

func GetHostname() string

GetHostname returns the servers hostname which we should compare against webserver vhost entries. Also includes domain.

func Glob

func Glob(subj, pattern string) bool

Glob will test a string pattern, potentially containing globs, against a string.

func IsDomainURL

func IsDomainURL(host, port string) (*url.URL, error)

IsDomainURL should validate the data we are obtaining from the webservers to ensure it is a proper hostname and/or port (within reason. custom configs are custom)

func LookupIP

func LookupIP(host string) (string, error)

LookupIP returns the first IP address from the resolving A record

func MustURL

func MustURL(host, port string) *url.URL

MustURL is much like isDomainURL, however will panic on error (useful for tests).

func NewFuncReader

func NewFuncReader(handler func([]byte), r io.Reader) io.Reader

NewFuncReader returns an io.Reader that wraps the given io.Reader with the given handler. If any of the parameters are nil, nil is returned.

func NewFuncWriter

func NewFuncWriter(handler func(*[]byte), w io.Writer) io.Writer

NewFuncWriter returns an io.Writer that wraps the given io.Writer with the given handler. Any Write() operations will run through the handler before being written. If any of the parameters are nil, nil is returned.

Types

type Timer

type Timer struct {
	Result *TimerResult
	// contains filtered or unexported fields
}

Timer represents a custom timer, holding start/end nanoseconds

func NewTimer

func NewTimer() *Timer

NewTimer returns a new Timer struct

func (*Timer) End

func (t *Timer) End()

End completes a timer and calculates the differences

func (*Timer) Start

func (t *Timer) Start()

Start starts a timer and returns a Timer struct

type TimerResult

type TimerResult struct {
	Milli   int64
	Seconds int64
}

TimerResult is a result of an ended timer, providing easy millisecond and second calculations to the process time

Jump to

Keyboard shortcuts

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