util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFilePresent

func IsFilePresent(filepath string) bool

IsFilePresent returns true if a file with the given path exists. If the path points to a directory, it also returns false.

Types

type Log

type Log struct {
	Context string
}

Log provides logging methods. Provide the given context (file or package name for example) to be displayed in the log messages.

func (*Log) D

func (l *Log) D(method string, msg string)

D writes the given message to log output

func (*Log) E

func (l *Log) E(method string, err error)

E writes the given error to log output

type StringRingList

type StringRingList struct {
	Items []string
	// contains filtered or unexported fields
}

StringRingList represents a ringed list of strings. You can retrieve items by calling Next().

func NewFileRingList

func NewFileRingList(root string) StringRingList

NewFileRingList will construct a new StringRingList containing the relative pathes to all files within the given directory.

func (*StringRingList) Next

func (list *StringRingList) Next() (string, error)

Next returns the next item form the ring list. Wrap around is done automatically, so no need to check current index. It will throw an error, if the list is empty.

func (*StringRingList) Shuffle added in v0.3.0

func (list *StringRingList) Shuffle()

Shuffle randomizes the order of elements in the given list

type TimeInterval

type TimeInterval struct {
	StartHour int
	EndHour   int
}

TimeInterval defines a time interval, determined by start and end hour

func (*TimeInterval) Contains

func (interval *TimeInterval) Contains(t time.Time) bool

Contains checks if the given time is within the given interval. The date part is ignored.

Jump to

Keyboard shortcuts

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