util

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package util haters gonna hate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasePath

func BasePath(s string) string

BasePath returns a normalized base path, stripping the leading '/' if present.

func Camelcase

func Camelcase(s string, v ...interface{}) string

Camelcase string with optional args.

func ClearHeader

func ClearHeader(h http.Header)

ClearHeader removes all header fields.

func Domain

func Domain(s string) string

Domain returns the effective domain. For example the string "api.example.com" becomes "example.com", while "api.example.co.uk" becomes "example.co.uk".

func Env

func Env(m map[string]string) (env []string)

Env returns a slice from environment variable map.

func Exists

func Exists(path string) bool

Exists returns true if the file exists.

func ExitStatus

func ExitStatus(cmd *exec.Cmd, err error) string

ExitStatus returns the exit status of cmd.

func Fatal

func Fatal(err error)

Fatal error.

func Indent

func Indent(s string) string

Indent the given string.

func IsJSON

func IsJSON(s string) bool

IsJSON returns true if the string looks like json.

func IsJSONLog

func IsJSONLog(s string) bool

IsJSONLog returns true if the string looks likes a json log.

func IsListening

func IsListening(u *url.URL) bool

IsListening returns true if there's a server listening on `u`.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if err is not nil and represents a missing resource.

func IsThrottled

func IsThrottled(err error) bool

IsThrottled returns true if err is not nil and represents a throttled request.

func Log

func Log(msg string, v ...interface{})

Log outputs a log message.

func LogClear

func LogClear(msg string, v ...interface{})

LogClear clears the line and outputs a log message.

func LogListItem

func LogListItem(msg string, v ...interface{})

LogListItem outputs a list item.

func LogName

func LogName(name, msg string, v ...interface{})

LogName outputs a log message with name.

func LogPad

func LogPad(msg string, v ...interface{})

LogPad outputs a log message with padding.

func LogTitle

func LogTitle(msg string, v ...interface{})

LogTitle outputs a log title.

func ManagedByUp

func ManagedByUp(s string) string

ManagedByUp appends "Managed by Up".

func Md5

func Md5(s string) string

Md5 returns an md5 hash for s.

func Milliseconds

func Milliseconds(d time.Duration) int

Milliseconds returns the duration as milliseconds.

func MillisecondsSince

func MillisecondsSince(t time.Time) int

MillisecondsSince returns the duration as milliseconds relative to time t.

func NewInlineProgressInt

func NewInlineProgressInt(total int) *progress.Bar

NewInlineProgressInt with the given total.

func NewProgressInt

func NewProgressInt(total int) *progress.Bar

NewProgressInt with the given total.

func Pad

func Pad() func()

Pad helper.

func ParseDuration

func ParseDuration(s string) (d time.Duration, err error)

ParseDuration string with day and month approximation support.

func ParseSections

func ParseSections(r io.Reader) (sections []string, err error)

ParseSections returns INI style sections from r.

func PrefixLines

func PrefixLines(s string, prefix string) string

PrefixLines prefixes the lines in s with prefix.

func ReadFileJSON

func ReadFileJSON(path string, v interface{}) error

ReadFileJSON reads json from the given path.

func StringsContains

func StringsContains(list []string, s string) bool

StringsContains returns true if list contains s.

func ToFloat

func ToFloat(v interface{}) float64

ToFloat returns a float or NaN.

func WaitForListen

func WaitForListen(u *url.URL, timeout time.Duration) error

WaitForListen blocks until `u` is listening with timeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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