utils

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FormatTime = "20060102150405"

Variables

View Source
var FileRegexp = regexp.MustCompile(`(\d{14})_(.*)\.go`)
View Source
var TimeRegexp = regexp.MustCompile(`\d{14}`)

Functions

func CreateOrOpenFile

func CreateOrOpenFile(path string) (*os.File, error)

func GetModuleName

func GetModuleName() (string, error)

func Map

func Map[T any, U any](slice []T, f func(T) U) []U

func MigrationFileFormat

func MigrationFileFormat(t time.Time, name string) string

func MigrationStructName

func MigrationStructName(t time.Time, name string) string

func MustJSON

func MustJSON(v interface{}) string

func NilOrValue

func NilOrValue[T any](t T) *T

NilOrValue If the value is a default value for the type, it returns nil else it returns the value.

func Parentheses

func Parentheses(in string) string

func ParseMigrationVersion

func ParseMigrationVersion(f string) (string, error)

func Ptr

func Ptr[T any](t T) *T

Ptr returns a pointer to the value passed as argument.

func RemoveConsecutiveSpaces

func RemoveConsecutiveSpaces(s string) (string, error)

RemoveConsecutiveSpaces Remove all whitespace not between matching unescaped quotes. Example: SELECT * FROM "table" WHERE "column" = 'value ' Result: SELECT * FROM "table" WHERE "column" = 'value '

func StrFunc

func StrFunc[T any](val T) func() string

StrFunc returns a function that returns the given value as a string

func StrFuncPredicate

func StrFuncPredicate[T any](condition bool, val T) func() string

func StringJoin

func StringJoin[T any](slice []T, sep string) string

Types

type Replacer

type Replacer map[string]func() string

func (Replacer) Replace

func (r Replacer) Replace(str string) string

Replace replaces the string with the given values {<key>} to the value of the function

Directories

Path Synopsis
Package logger is almost copy/paste from tint Handler but with some modificatoins
Package logger is almost copy/paste from tint Handler but with some modificatoins

Jump to

Keyboard shortcuts

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