utils

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 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

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

func AddFilesToZip

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

func AddItemsToSet

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

func ConvertIntSlice

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

func FilesEqual

func FilesEqual(aPath, bPath string) error

func FixUserId

func FixUserId(userId string) string

func GetMapKeys

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

func ImagesEqual

func ImagesEqual(aPath, bPath string) error

func ItemInSlice

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

func MakeScanImage(
	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

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

func SlicesEqual

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