core_utils

package module
v0.0.0-...-25d2a20 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 21 Imported by: 0

README

Core Util Functions

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

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 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 Debug

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

func DebugError

func DebugError(err error)

func DirectoryExists

func DirectoryExists(path string) bool

func ErrorMessage

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

func ErrorWarning

func ErrorWarning(e error)

func FatalOnErr

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

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 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 ImportantDebug

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

func IntToString

func IntToString(i int) string

func IsDebugMode

func IsDebugMode() bool

func IsValidEmail

func IsValidEmail(email 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 NewError

func NewError(params ...interface{}) error

func Notice

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

func PrintAndPanic

func PrintAndPanic(err interface{})

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 PrintValidationError

func PrintValidationError(err validator.FieldError)

func PrintWarningMessage

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

func RandomString

func RandomString(length int) string

func RawSha256

func RawSha256(data []byte) string

func Sha256

func Sha256(data string) string

func StopOnError

func StopOnError(err interface{})

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 ValidateStruct

func ValidateStruct(s interface{}) error

func Warning

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

func WriteToFile

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

Types

type ConfContent

type ConfContent []byte

func GetConfigContent

func GetConfigContent(file string) ConfContent

func (*ConfContent) ReplaceImports

func (c *ConfContent) ReplaceImports()

func (*ConfContent) ToStringLines

func (c *ConfContent) ToStringLines() []string

type StructValidatorResult

type StructValidatorResult []validator.FieldError

func ValidateGenericStruct

func ValidateGenericStruct(s interface{}) StructValidatorResult

func (StructValidatorResult) HasFieldErrorFor

func (s StructValidatorResult) HasFieldErrorFor(field string) bool

func (StructValidatorResult) SingleError

func (s StructValidatorResult) SingleError() error

type Tester

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

type UrlString

type UrlString string

func (UrlString) ToPath

func (u UrlString) ToPath() string

Jump to

Keyboard shortcuts

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