utils

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DATE_FORMAT     = "2006-01-02"
	DATETIME_FORMAT = "2006-01-02 03-04-05"
)

Variables

This section is empty.

Functions

func BatchGet added in v0.0.28

func BatchGet[T any](ids []string, reqMaker func(string) (T, error)) (out map[string]T)

func EncodeURIComponent added in v0.0.14

func EncodeURIComponent(str string) string

func EnsureDirOf

func EnsureDirOf(path string) error

func ExpandUserPath

func ExpandUserPath(path string) string

func Filter added in v0.0.23

func Filter[T any](items []T, filtfunc func(T) bool) (out []T)

func FormatDate

func FormatDate(t time.Time) string

func FormatTime

func FormatTime(t time.Time) string

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

func JsonDecodeBytes

func JsonDecodeBytes(bytes []byte) (interface{}, error)

func JsonDecodeStr

func JsonDecodeStr(str string) (interface{}, error)

func JsonGet

func JsonGet(url string, onReq func(req *http.Request)) (interface{}, *http.Response, error)

func JsonReadFile added in v0.0.24

func JsonReadFile(path string) (interface{}, error)

func JsonToQueryString

func JsonToQueryString(json StringMap) string

func JsonWriteFile added in v0.0.24

func JsonWriteFile(data interface{}, path string, perm os.FileMode) error

func Map added in v0.0.22

func Map[T any, U any](items []T, mapfunc func(T) U) (out []U)

func NeedsRefresh

func NeedsRefresh(refresh_type int32, last_refreshed_at time.Time, now time.Time) bool

func OpenBrowser added in v0.0.4

func OpenBrowser(url string)

*

  • Opens the browser pointing to a given URL.

func ParseDate

func ParseDate(str string) time.Time

func ParseTime

func ParseTime(str string) time.Time

func PriceString

func PriceString(value float64) string

Types

type DefaultMap added in v0.0.18

type DefaultMap[V interface{}] struct {
	// contains filtered or unexported fields
}

func NewDefaultMap added in v0.0.18

func NewDefaultMap[V any](creator func(key string) V) *DefaultMap[V]

func (*DefaultMap[V]) Ensure added in v0.0.18

func (tm *DefaultMap[V]) Ensure(key string) V

func (*DefaultMap[V]) Get added in v0.0.18

func (tm *DefaultMap[V]) Get(key string) (V, bool)

type StringMap

type StringMap = map[string]interface{}

Jump to

Keyboard shortcuts

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