Documentation ¶
Index ¶
- func AllCPUs() int
- func BeginOfThisMonth(tz *time.Location) time.Time
- func BeginOfThisWeek(tz *time.Location) time.Time
- func BeginOfThisYear(tz *time.Location) time.Time
- func BeginOfToday(tz *time.Location) time.Time
- func CeilDate(date time.Time) time.Time
- func CheckEmailMX(email string) bool
- func CloneStringMap(m map[string]string, keysToLower bool) map[string]string
- func CompareArgon2Id(hashed, plain, pepper string) bool
- func CompareBcrypt(hashed, plain, pepper string) bool
- func ComparePassword(hashed, plain, pepper string) bool
- func CronPadToSecondly(expr string) string
- func ExtractBasicAuth(r *http.Request) (username, password string, err error)
- func ExtractBearerAuth(r *http.Request) (key string, err error)
- func FadeColors(color1, color2 color.RGBA, ratio float64) color.RGBA
- func FindString(needle string, haystack []string, defaultVal string) string
- func HalfCPUs() int
- func HasConstraints(db *gorm.DB) bool
- func HashArgon2Id(plain, pepper string) (string, error)
- func HashBcrypt(plain, pepper string) (string, error)
- func HashPassword(plain, pepper string) (string, error)
- func HexToRGBA(s string) (c color.RGBA)
- func IsCleanDB(db *gorm.DB) bool
- func IsNoCache(r *http.Request, cacheTtl time.Duration) bool
- func Json(data interface{}) template.JS
- func LocalTZOffset() time.Duration
- func MustParseTime(layout, value string) time.Time
- func ParseJsonDropKeys[T any](r io.Reader, dropKeys ...string) (T, error)
- func ParseUserAgent(ua string) (string, string, error)
- func ParseWeekday(s string) time.Weekday
- func QuoteDbIdentifier(db *gorm.DB, identifier string) string
- func QuoteSql(db *gorm.DB, queryTemplate string, identifiers ...string) string
- func RGBAToHex(c color.RGBA) string
- func RaiseForStatus(res *http.Response, err error) (*http.Response, error)
- func SplitMulti(s string, delimiters ...string) []string
- func SplitRangeByDays(from time.Time, to time.Time) [][]time.Time
- func SubSlice[T any](slice []T, from, to uint) []T
- func ToRunes(s string) (r []string)
- func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
- func WhereNullable(query *gorm.DB, col string, val any) *gorm.DB
- func WithPaging(query *gorm.DB, limit, skip int) *gorm.DB
- func WithRecovery(fn func(...interface{}), args ...interface{}) (err error)
- func WithRecovery1[T any](fn func(T), a1 T) (err error)
- type PageParams
- type TemplateMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CeilDate ¶
CeilDate rounds date up to the start of next day if date is not already a start (00:00:00)
func CheckEmailMX ¶
CheckEmailMX takes an e-mail address and verifies that an MX DNS record exists for its domain
func CompareArgon2Id ¶
func CompareBcrypt ¶
func ComparePassword ¶
func CronPadToSecondly ¶
func ExtractBasicAuth ¶
func HasConstraints ¶
func HashArgon2Id ¶
func HashBcrypt ¶
func HashPassword ¶
func IsNoCache ¶
IsNoCache checks whether returning a cached resource no older than cacheTtl is allowed given the incoming request
func LocalTZOffset ¶
LocalTZOffset returns the time difference between server local time and UTC
func MustParseTime ¶
func ParseJsonDropKeys ¶
ParseJsonDropKeys parses the given JSON input object to an object of given type, while omitting the specified keys on the way. This can be useful if parsing would normally fail due to ambiguous typing of some key, but that key is not of interest and can be dropped to avoid parse errors. Dropping keys only works on top level of the object.
func ParseWeekday ¶
func QuoteDbIdentifier ¶
QuoteDbIdentifier quotes a column name used in a query.
func SplitMulti ¶
func SplitRangeByDays ¶
SplitRangeByDays creates a slice of intervals between from and to, each of which is at max of 24 hours length and has its split at midnight
func WaitTimeout ¶
WaitTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out. See // https://stackoverflow.com/a/32843750/3112139.
func WithRecovery ¶
func WithRecovery(fn func(...interface{}), args ...interface{}) (err error)
WithRecovery executes a given function while recovering from panics and returning them as an errors
func WithRecovery1 ¶
WithRecovery1 executes a given function with one parameter while recovering from panics and returning them as an errors
Types ¶
type PageParams ¶
func ParsePageParams ¶
func ParsePageParams(r *http.Request) *PageParams
func ParsePageParamsWithDefault ¶
func ParsePageParamsWithDefault(r *http.Request, page, size int) *PageParams
func (*PageParams) Limit ¶
func (p *PageParams) Limit() int
func (*PageParams) Offset ¶
func (p *PageParams) Offset() int