utils

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUpGeneratedFiles

func CleanUpGeneratedFiles(dir string) error

CleanUpGeneratedFiles deletes everything at folder dir.

func DBClose

func DBClose(db *sql.DB)

DBClose closes non nil db connection

func DirExists

func DirExists(path string) (bool, error)

DirExists checks if folder at path exist.

func EnsureDirPath

func EnsureDirPath(dirPath string) error

EnsureDirPath ensures dir path exists. If path does not exist, creates new path.

func ErrorCatch

func ErrorCatch(err *error)

ErrorCatch is used in defer to recover from panics and to set err

func ExtractDateTimeComponents

func ExtractDateTimeComponents(duration time.Duration) (days, hours, minutes, seconds, microseconds int64)

ExtractDateTimeComponents extracts number of days, hours, minutes, seconds, microseconds from duration

func IsNil

func IsNil(v interface{}) bool

IsNil check if v is nil

func MustBe

func MustBe(v interface{}, kind reflect.Kind, errorStr string)

MustBe panics with errorStr error, if v interface is not of reflect kind

func MustBeInitializedPtr

func MustBeInitializedPtr(val interface{}, errorStr string)

MustBeInitializedPtr panics with errorStr if val interface is nil

func MustBeTrue

func MustBeTrue(condition bool, errorStr string)

MustBeTrue panics when condition is false

func PanicOnError

func PanicOnError(err error)

PanicOnError panics if err is not nil

func SaveGoFile

func SaveGoFile(dirPath, fileName string, text []byte) error

SaveGoFile saves go file at folder dir, with name fileName and contents text.

func StringSliceContains

func StringSliceContains(strings []string, contains string) bool

StringSliceContains checks if slice of strings contains a string

func ToGoEnumValueIdentifier

func ToGoEnumValueIdentifier(enumName, enumValue string) string

ToGoEnumValueIdentifier converts enum value name to Go identifier name.

func ToGoFileName

func ToGoFileName(databaseIdentifier string) string

ToGoFileName converts database identifier to Go file name.

func ToGoIdentifier

func ToGoIdentifier(databaseIdentifier string) string

ToGoIdentifier converts database to Go identifier.

func TypeMustBe

func TypeMustBe(v reflect.Type, kind reflect.Kind, errorStr string)

TypeMustBe panics with errorStr error, if v type is not of reflect kind

func ValueMustBe

func ValueMustBe(v reflect.Value, kind reflect.Kind, errorStr string)

ValueMustBe panics with errorStr error, if v value is not of reflect kind

Types

This section is empty.

Jump to

Keyboard shortcuts

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