util

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Diff = diff.Diff
View Source
var ErrorTokenExpired = fmt.Errorf("Token expired")
View Source
var ErrorTokenInvalid = fmt.Errorf("Token invalid")

Functions

func CalcExpiry

func CalcExpiry(days int) string

func CheckToken

func CheckToken(secret, expiry, input, token string) error

func CombineDateTimePair added in v0.0.9

func CombineDateTimePair(d, t time.Time) time.Time

func Contains added in v0.0.11

func Contains(str []string, target string) bool

func DaysBetween

func DaysBetween(start, end time.Time) []time.Time

func DefaultedDatesFromForm added in v0.0.17

func DefaultedDatesFromForm(form Gettable, numDaysFromNowDefault int, weekBoundary bool) (startTime, endTime time.Time, err error)

func DiffOnly

func DiffOnly(one, two string) string

func FirstChar

func FirstChar(input string) string

func FirstFiveChars

func FirstFiveChars(input string) string

func FirstNonEmptyString

func FirstNonEmptyString(inputs ...string) string

func GetTxCtx

func GetTxCtx(db *sql.DB) (context.Context, *sql.Tx, error)

func Hash

func Hash(str string) string

func HashPassword

func HashPassword(rawpassword string) (string, error)

func IsBetween

func IsBetween(target, start, end time.Time) bool

func IsWeekday

func IsWeekday(day time.Time) bool

func IsWeekend

func IsWeekend(day time.Time) bool

func NextDay

func NextDay(begin time.Time, target time.Weekday) time.Time

func NextFlow added in v0.0.17

func NextFlow(defaultURL string, form url.Values) string

func Overlap added in v0.0.25

func Overlap(one, two Interval) bool

func Parallelize

func Parallelize(functions ...func() error) (errors []error)

func ParseDateTimePair added in v0.0.9

func ParseDateTimePair(d, t string, loc *time.Location) (time.Time, error)

func Pluralise added in v0.0.10

func Pluralise(num int, singular string, plural string) string

func Prefix

func Prefix(strs []string, prefix string) []string

func PrettyJsonString

func PrettyJsonString(input string) string

func PrevDay added in v0.0.21

func PrevDay(begin time.Time, target time.Weekday) time.Time

func RollbackTx

func RollbackTx(ctx context.Context) error

func RootPath added in v0.0.19

func RootPath(in *url.URL) string

func SelectorSafe added in v0.0.32

func SelectorSafe(in string) string

func StripBlankStrings

func StripBlankStrings(input []string) []string

func Truncate added in v0.0.32

func Truncate(num int, input string) string

func Uniq

func Uniq(input []string) []string

Types

type ClientSafeError

type ClientSafeError struct {
	Message string
}

func (ClientSafeError) ClientSafeMessage

func (err ClientSafeError) ClientSafeMessage() string

func (ClientSafeError) Error

func (err ClientSafeError) Error() string

type Gettable added in v0.0.17

type Gettable interface {
	// For example, url.Values
	Get(string) string
}

type IntMap

type IntMap map[string]int

func (*IntMap) Scan

func (p *IntMap) Scan(src interface{}) error

func (IntMap) Value

func (p IntMap) Value() (driver.Value, error)

type Interval added in v0.0.25

type Interval struct {
	Start time.Time
	End   time.Time
}

type NullStringList added in v0.0.16

type NullStringList struct {
	Valid   bool
	Strings pq.StringArray
}

func (*NullStringList) Scan added in v0.0.16

func (n *NullStringList) Scan(value interface{}) error

func (NullStringList) Value added in v0.0.16

func (n NullStringList) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Period

type Period struct {
	Start time.Time
	End   time.Time
}

func (Period) Next

func (this Period) Next() Period

func (Period) Prev

func (this Period) Prev() Period

type StringMap

type StringMap map[string]string

func (*StringMap) Scan

func (p *StringMap) Scan(src interface{}) error

func (StringMap) Value

func (p StringMap) Value() (driver.Value, error)

type Token

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

func CalcToken

func CalcToken(secret string, days int, input string) Token

func (Token) ExpiryString

func (this Token) ExpiryString() string

func (Token) String

func (this Token) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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