utils

package
v3.4.232 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images

Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images

Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images

Exposes various utility functions for strings, generation of valid filenames and random ID strings, zipping files/directories, reading/writing images

Example (MakeSaveableFileName)
fmt.Println(MakeSaveableFileName("my roi"))
fmt.Println(MakeSaveableFileName("Dust/Alteration"))
fmt.Println(MakeSaveableFileName("I bet $100 this is cheese"))
fmt.Println(MakeSaveableFileName("10% Ca/Fe & Coffee matrix?"))
Output:
my roi
Dust Alteration
I bet  100 this is cheese
10% Ca Fe   Coffee matrix

Index

Examples

Constants

View Source
const PrettyPrintIndentForJSON = "    "

PrettyPrintIndentForJSON Pretty-print indenting of JSON

Variables

This section is empty.

Functions

func Abs added in v3.4.232

func Abs[T constraints.Integer](val T) T

func AddFilesToZip

func AddFilesToZip(w *zip.Writer, basePath, baseInZip string)

func AddItemsToSet added in v3.4.232

func AddItemsToSet[K comparable](keys []K, theSet map[K]bool)

func ConvertIntSlice added in v3.4.232

func ConvertIntSlice[T constraints.Integer, F constraints.Integer](from []F) []T

func FilesEqual

func FilesEqual(aPath, bPath string) error

func FixUserId added in v3.4.232

func FixUserId(userId string) string

func GetMapKeys added in v3.4.232

func GetMapKeys[K comparable, V any](theMap map[K]V) []K

func ImagesEqual

func ImagesEqual(aPath, bPath string) error

func ItemInSlice added in v3.4.232

func ItemInSlice[T comparable](a T, list []T) bool

func MakeSaveableFileName

func MakeSaveableFileName(name string) string

MakeSaveableFileName - Given a name which may not be acceptable as a file name, generate a string for a file name that won't have issues. This replaces bad characters like slashes with spaces, etc

func MakeScanImage added in v3.4.232

func MakeScanImage(
	imgName string,
	imgPath string,
	fileSize uint32,
	source protos.ScanImageSource,
	purpose protos.ScanImagePurpose,
	associatedScanIds []string,
	originScanId string,
	originImageURL string,
	matchInfo *protos.ImageMatchTransform,
	img image.Image) *protos.ScanImage

func RandStringBytesMaskImpr

func RandStringBytesMaskImpr(n int) string

func ReadFileLines

func ReadFileLines(filePath string) ([]string, error)

ReadFileLines - Reads all lines in a file into a string array

func ReadImageFile

func ReadImageFile(path string) (image.Image, error)

func RemoveItemFromSlice added in v3.4.232

func RemoveItemFromSlice[T comparable](a T, list []T) []T

func SendProtoBinary added in v3.4.232

func SendProtoBinary(w http.ResponseWriter, m protoreflect.ProtoMessage)

func SendProtoJSON added in v3.4.232

func SendProtoJSON(w http.ResponseWriter, m protoreflect.ProtoMessage)

func SlicesEqual added in v3.4.232

func SlicesEqual[T comparable](listA []T, listB []T) bool

func UnzipDirectory

func UnzipDirectory(src string, dest string, flattenPaths bool) ([]string, error)

func WritePNGImageFile

func WritePNGImageFile(pathPrefix string, img image.Image) error

func ZipDirectory

func ZipDirectory(dirPath string) ([]byte, error)

ZipDirectory - zips a whole directory and its contents (NOT recursive!) See: https://golang.org/pkg/archive/zip/#example_Writer

Types

This section is empty.

Jump to

Keyboard shortcuts

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