common

package module
v0.0.0-...-d58892d Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(e error)

Check check for error and panics, if not nil

func CheckEmail

func CheckEmail(email string) (ok bool)

CheckEmail checks e-mail format correctness

func ElapsedMs

func ElapsedMs(start time.Time) float64

ElapsedMs returns elapsed time between now and arg as ms

func ErrorTraced

func ErrorTraced(prev error, args ...string) error

ErrorTraced mimics panic() output.

Usage: return ErrorTraced(err, inputAgrs...)

func FromGob

func FromGob(by []byte, m interface{})

FromGob - go binary decoder

func Log

func Log(shoudLog bool, format string, a ...interface{})

Log writes to stdout if shoudLog flag is true

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

PrettyPrint prints objects prettier

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack logs elapsed time for task

func ToGob

func ToGob(m interface{}) []byte

ToGob - go binary encoder

func Trace

func Trace()

Trace logs current code line trace

Types

type TimeRemainingTimer

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

TimeRemainingTimer used to track progress

func CreateTimeRemainingTimer

func CreateTimeRemainingTimer(start, end int64) *TimeRemainingTimer

CreateTimeRemainingTimer creates timer, that will interpolate remaining time based on some start & end indexes

func (*TimeRemainingTimer) Get

func (v *TimeRemainingTimer) Get(current int64) (percentageDone float64, timeRemaining time.Duration)

Get returns %done & remainingTime for current index

func (*TimeRemainingTimer) Getf

func (v *TimeRemainingTimer) Getf(current int64) string

Getf returns formatted string of %done & remaining time

func (*TimeRemainingTimer) Printr

func (v *TimeRemainingTimer) Printr(current int64)

Printr fmt.Printf's formatted %done & remaining time

func (*TimeRemainingTimer) Restart

func (v *TimeRemainingTimer) Restart(start, end int64)

Restart restarts the timer with new start & end values

func (*TimeRemainingTimer) Start

func (v *TimeRemainingTimer) Start()

Start starts the timer

Jump to

Keyboard shortcuts

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