core_utils

package module
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 21 Imported by: 3

README

Core Util Functions

  1. Printing
  2. Working with files and directories
  3. Working with data types
  4. Database utils

Version: v1.0.3

git tag -a v1.0.3 -m "v1.0.3"
git push origin v1.0.3

Go run tests

go test ./...

Documentation

Index

Constants

View Source
const NoFileHash = "noFile"

Variables

This section is empty.

Functions

func AMatchesB

func AMatchesB[T comparable](t *testing.T, expected T, actual T)

func AMatchesBDetailed added in v1.0.7

func AMatchesBDetailed[T comparable](t *testing.T, expected T, actual T)

func AbsPath

func AbsPath(path string) string

func AllowDebug

func AllowDebug()

func AllowNotice

func AllowNotice()

func CamelCaseToSnakeCase

func CamelCaseToSnakeCase(s string) string

func CliError

func CliError(msg ...interface{})

func CopyStructToDefault

func CopyStructToDefault[T interface{}](src, dst T) T

func CreateFilepathDir added in v1.0.11

func CreateFilepathDir(filePath string) error

func Debug

func Debug(f string, a ...interface{})

func DebugError

func DebugError(err error)

func DirectoryExists

func DirectoryExists(path string) bool

func DisallowNotice added in v1.0.12

func DisallowNotice()

func ErrorMessage

func ErrorMessage(msg string, p ...interface{})

func ErrorWarning

func ErrorWarning(e error)

func FatalOnErr

func FatalOnErr(t *testing.T, err error)

func FieldErrorWarning added in v1.0.39

func FieldErrorWarning(err validator.FieldError)

func FileExists

func FileExists(path string) bool

func FirstLetterToUpper

func FirstLetterToUpper(s string) string

func FormattedJson

func FormattedJson(v interface{}) ([]byte, error)

func GetCallerDir

func GetCallerDir() string

func GetContentBetween

func GetContentBetween(start string, end string, content string) string

func GetFileContent

func GetFileContent(path string) (*bytes.Buffer, error)

func GetFileHash

func GetFileHash(path string) string

func GetFileListExcluding

func GetFileListExcluding(rootPath string, excluded []string) []string

func GetFilesList

func GetFilesList(rootPath string) []string

func GetRelativePath

func GetRelativePath(dir string, path string) string

func HasFieldError added in v1.0.40

func HasFieldError(field string, err error) bool

func HashPassword

func HashPassword(pass string) string

func HiGreen

func HiGreen(f string, a ...interface{})

func IF

func IF[T any](cond bool, vtrue, vfalse T) T

func IntToString

func IntToString(i int) string

func IsDebugMode

func IsDebugMode() bool

func IsDir added in v1.0.12

func IsDir(path string) bool

func LoadStructFromBytes

func LoadStructFromBytes(s interface{}, data []byte) error

func LoadStructFromFile

func LoadStructFromFile(s interface{}, yamlPath string) error

func LogTimeElapsed

func LogTimeElapsed(start time.Time, name string)

func MustGetFileContent

func MustGetFileContent(path string) *bytes.Buffer

func Notice

func Notice(f string, a ...interface{})

func PanicOnError added in v1.0.21

func PanicOnError(err error)

func PrintAndPanic

func PrintAndPanic(err interface{})

func PrintCallStack added in v1.0.36

func PrintCallStack()

func PrintError

func PrintError(err string, params ...interface{})

func PrintMessage

func PrintMessage(f string, a ...interface{})

func PrintServerResponse

func PrintServerResponse(f string, a ...interface{})

func PrintWarningMessage

func PrintWarningMessage(f string, a ...interface{})

func RandomString

func RandomString(length int) string

func RawSha256

func RawSha256(data []byte) string

func RecoverPanicAsError added in v1.0.27

func RecoverPanicAsError(err *error) func()

func RecoverPanicPrint added in v1.0.27

func RecoverPanicPrint() func()

func Sha256

func Sha256(data string) string

func SimpleStructValidation added in v1.0.39

func SimpleStructValidation(s interface{}) error

func SnakeCaseToCamelCase added in v1.0.14

func SnakeCaseToCamelCase(s string) string

func StopAndNotify added in v1.0.4

func StopAndNotify(msg string, p ...interface{})

func StopOnError

func StopOnError(err interface{})

func StopOnPanic added in v1.0.27

func StopOnPanic() func()

func StringToInt

func StringToInt(s string) int

func TestFailMessage

func TestFailMessage(f string, a ...interface{}) string

func Title

func Title(s string) string

func ToString

func ToString(s interface{}) string

func ToStringPointer

func ToStringPointer(s string) *string

func ValidateAndWarn added in v1.0.39

func ValidateAndWarn(s interface{}) error

func ValidateWithCustomFunc added in v1.0.39

func ValidateWithCustomFunc(s interface{}, validators map[string]validator.Func) error

func Warning

func Warning(f string, a ...interface{})

func WriteToFile

func WriteToFile(path string, data *bytes.Buffer) error

Types

type Tester

type Tester struct {
	// contains filtered or unexported fields
}

type UrlString

type UrlString string

func (UrlString) ToPath

func (u UrlString) ToPath() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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