util

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckYes

func CheckYes(scnr scanner, msg string, defaultYes bool) bool

CheckYes takes a message string to present to the user and a boolen value representing the default value. It scans input for text. If the input value is empty, the default value is returned. If the input is either "y", "yes" (any case) true is returned. Otherwise, false is returned.

func GetInputInt

func GetInputInt(scnr scanner, msg string, def int) int

GetInputInt takes a message string to present to the user and a default value. It scans input for text and attempts to convert the input to an integer. If the conversion to an integer fails, the user will be prompted to input an integer again. If the input value is empty, the default value is returned. Otherwise, the converted integer is returned.

func GetInputString

func GetInputString(scnr scanner, msg, def string) string

GetInputString takes a message string to present to the user and a default value. It scans input for text. If the input value is empty, the default value is returned. Otherwise, the input string is returned.

func StringInSlice

func StringInSlice(a string, b []string) bool

StringInSlice takes a string and a string slice. If the string is equal to any value in the string slice, true is returned. Otherwise, false is returned.

func StringSliceEqual

func StringSliceEqual(a []string, b []string) bool

StringSliceEqual takes two string slices and compares all slice values are equal. If all values are equal, true is returned. Otherwise, false is returned.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock is implemented by any value that has a Now method.

type MockClock

type MockClock struct {
	NowTime time.Time
}

MockClock represents a clock that returns a settable time.

func (MockClock) Now

func (m MockClock) Now() time.Time

Now returns the time set in the NowTime field.

type RealClock

type RealClock struct{}

RealClock represents the system clock.

func (RealClock) Now

func (RealClock) Now() time.Time

Now returns the system time.

Jump to

Keyboard shortcuts

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