utils

package
v0.0.0-...-5ba6bf8 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 9 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 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 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

Jump to

Keyboard shortcuts

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