tools

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

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

README

tools

Go codecov Go Report Card GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppPath

func AppPath() string

AppPath returns the absolute path of the application's binary.

func Date

func Date(ti int64, format string) string

Date Format unix time int64 to string eg format: YYYY-MM-DD HH:mm:SS

func DateS

func DateS(ts string, format string) string

DateS Format unix time string to string

func DateT

func DateT(t time.Time, format string) string

DateT .. Format time.Time struct to string MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5

func EnsureAbs

func EnsureAbs(path string) string

EnsureAbs prepends the WorkDir to the given path if it is not an absolute path.

func IntSliceDifference

func IntSliceDifference(slice1, slice2 []int) []int

IntSliceDifference int slice difference

func IntSliceIntersect

func IntSliceIntersect(slice1, slice2 []int) []int

IntSliceIntersect ..

func IntSliceUnion

func IntSliceUnion(slice1, slice2 []int) []int

IntSliceUnion ..

func IsSliceContainsInt

func IsSliceContainsInt(sl []int, i int) bool

IsSliceContainsInt returns true if the int exists in given slice.

func IsSliceContainsInt64

func IsSliceContainsInt64(sl []int64, i int64) bool

IsSliceContainsInt64 returns true if the int64 exists in given slice.

func IsSliceContainsStr

func IsSliceContainsStr(sl []string, str string) bool

IsSliceContainsStr returns true if the string exists in given slice, ignore case.

func ParseDateToStr

func ParseDateToStr(timeValue time.Time, format string) string

ParseDateToStr .. MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5

func ParseStrToDate

func ParseStrToDate(timestr, format, locationName string) (time.Time, error)

ParseStrToDate .. timeStr format locationName, when locationName is "", defaultLocation rely on system env.

func TimeComparison

func TimeComparison(time1, time2 time.Time) int

TimeComparison time 0 equal, 1 time1 greater than time2 2 time1 less than time2

func WorkDir

func WorkDir() string

WorkDir returns the absolute path of work directory. It reads the value of envrionment variable GOGS_WORK_DIR. When not set, it uses the directory where the application's binary is located.

Types

type StrTo

type StrTo string

Convert string to specify type.

func (StrTo) Exist

func (f StrTo) Exist() bool

func (StrTo) Float64

func (f StrTo) Float64() (float64, error)

func (StrTo) Int

func (f StrTo) Int() (int, error)

func (StrTo) Int64

func (f StrTo) Int64() (int64, error)

func (StrTo) MustFloat64

func (f StrTo) MustFloat64() float64

func (StrTo) MustInt

func (f StrTo) MustInt() int

func (StrTo) MustInt64

func (f StrTo) MustInt64() int64

func (StrTo) MustUint8

func (f StrTo) MustUint8() uint8

func (StrTo) String

func (f StrTo) String() string

func (StrTo) Uint8

func (f StrTo) Uint8() (uint8, error)

Jump to

Keyboard shortcuts

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