utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 24 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExtensionIfNotExist added in v1.0.1

func AddExtensionIfNotExist(filePath string, extension string) string

func Clamp

func Clamp[T constraints.Ordered](v, low, high T) T

func ClampCycle

func ClampCycle[T constraints.Ordered](v, low, high T) T

func DownloadFile

func DownloadFile(filePath string, url string) error

func EnsureFolderExistForFile added in v1.0.1

func EnsureFolderExistForFile(filePath string) error

func ErrorHandler

func ErrorHandler(f func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc

func FileExists

func FileExists(filename string) bool

func GetEnv

func GetEnv(key, fallback string) string

func GetRandomSample

func GetRandomSample(s []string, n int) []string

func GetUrlAsText added in v1.0.2

func GetUrlAsText(url string) (string, error)

func InsertAt

func InsertAt[T any](a []T, index int, value T) []T

func LoadGob

func LoadGob(filename string, data any) error

func MakeMultipartPostRequest added in v1.0.1

func MakeMultipartPostRequest(url string, formData map[string]string, fileParamName, filePath string) (*http.Response, error)

func Max

func Max[T constraints.Ordered](a, b T) T

func MemUsageReport

func MemUsageReport() string

MemUsageReport outputs the current, total and OS memory being used. As well as the number of garage collection cycles completed.

func Min

func Min[T constraints.Ordered](a, b T) T

func ReadFileFromTarGz

func ReadFileFromTarGz(tarGzFile, extension string) (string, error)

Returns first found

func ReadFileInZip

func ReadFileInZip(zipPath string, targetFileName string) (string, error)

func ReadJSON

func ReadJSON(filename string, data any) error

func Remove

func Remove[T interface{}](s []T, i int) []T

order is not important

func RemoveExtension added in v1.0.1

func RemoveExtension(filePath string) string

func RemoveKeepOrder

func RemoveKeepOrder[T interface{}](slice []T, i int) []T

order is important

func SaveGob

func SaveGob(data any, filename string) error

func SaveResponseBodyToFile added in v1.0.1

func SaveResponseBodyToFile(response *http.Response, filePath string) error

func SetupConfigPath added in v1.0.1

func SetupConfigPath(rootPath string) error

func SetupLogger

func SetupLogger(debug bool, log_file_name string) error

func SetupTestConfig added in v1.0.1

func SetupTestConfig() error

func TimeTrack

func TimeTrack(start time.Time, name string)

func WriteJSON

func WriteJSON(filePath string, data any, prettyPrint bool, compress bool) error

func WriteStringArrayToFile added in v1.0.1

func WriteStringArrayToFile(strArray []string, filename string) error

Types

type GenericWebClient added in v1.0.2

type GenericWebClient struct {
	Hostname string
	Port     int
}

func (*GenericWebClient) GetUrl added in v1.0.2

func (c *GenericWebClient) GetUrl(endpoint string) string

type Point added in v1.0.1

type Point struct {
	X, Y int
}

func (*Point) SquaredDistanceFrom added in v1.0.1

func (p *Point) SquaredDistanceFrom(other *Point) float64

type Rect added in v1.0.1

type Rect struct {
	X, Y, W, H int
}

func (*Rect) BBCenter added in v1.0.1

func (rect *Rect) BBCenter() *Point

func (*Rect) Bottom added in v1.0.1

func (rect *Rect) Bottom() int

func (*Rect) Intersects added in v1.0.1

func (rect *Rect) Intersects(other *Rect) bool

func (*Rect) IsValid added in v1.0.1

func (rect *Rect) IsValid() bool

func (*Rect) Left added in v1.0.1

func (rect *Rect) Left() int

func (*Rect) Reset added in v1.0.1

func (rect *Rect) Reset()

func (*Rect) Right added in v1.0.1

func (rect *Rect) Right() int

func (*Rect) Top added in v1.0.1

func (rect *Rect) Top() int

Jump to

Keyboard shortcuts

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