utils

package
v0.0.0-...-2de8f8b Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logrus.New()

Logger is a global logging instance has to be used everywhere

Functions

func ConvertTimestamp

func ConvertTimestamp(timestamp int64) *time.Time

ConvertTimestamp converts timestamp to time structure

func DisableLogging

func DisableLogging()

DisableLogging disables logging.

func EnableLogging

func EnableLogging()

EnableLogging enables verbose logging mode.

func Exec

func Exec(cmd string, shell string, interactive bool, pseudoTTY bool, stdin io.Reader, stdout io.Writer, stderr io.Writer) *exec.ExitError

Exec runs a command with connected streams and according to the TTY usage.

func GetStatusCode

func GetStatusCode(err *exec.ExitError) int

GetStatusCode returns an exit code from exec.ExitError

func Open

func Open(filename string) (handler *os.File)

Open just a small wrapper on os.Open which panics if something goes wrong.

func RemoveWithLogging

func RemoveWithLogging(fileName string) error

RemoveWithLogging does the same as os.Remove does but logs.

func SplitCommandToChunks

func SplitCommandToChunks(cmd string) (string, []string)

SplitCommandToChunks splits a command to the command name and its arguments.

Types

type Regexp

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

Regexp is just a wrapper to play with different regular expression libraries to get the best one.

func CreateRegexp

func CreateRegexp(expression string) *Regexp

CreateRegexp creates a regexp with MustCompile (or equialent) method.

func (*Regexp) Groups

func (r *Regexp) Groups(suspected string) (groups []string, err error)

Groups returns a slice of a groups of regular expression applied to the string.

func (*Regexp) Match

func (r *Regexp) Match(suspected string) bool

Match verifies that suspected string matches regular expression.

type SynchronizedWriter

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

SynchronizedWriter provides WriteCloser interface with mutexed operations.

func NewSynchronizedWriter

func NewSynchronizedWriter(writer io.WriteCloser) (sw *SynchronizedWriter)

NewSynchronizedWriter makes writer synchronized.

func (*SynchronizedWriter) Close

func (sw *SynchronizedWriter) Close() (err error)

Close closes content to the writer mutually exclusive.

func (*SynchronizedWriter) Write

func (sw *SynchronizedWriter) Write(content []byte) (n int, err error)

Write writes content to the writer mutually exclusive.

Jump to

Keyboard shortcuts

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