Documentation ¶
Overview ¶
Example (GenObjectID) ¶
Checking that our IDs are pretty random...
rand.Seed(time.Now().UnixNano()) ids := map[string]bool{} var g IDGen for c := 0; c < 1000000; c++ { id := g.GenObjectID() _, exists := ids[id] if exists { fmt.Printf("match: %v\n", c) break } ids[id] = true } fmt.Println("done")
Output: done
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 ¶
- Constants
- func AbsI64(x int64) int64
- func AddFilesToZip(w *zip.Writer, basePath, baseInZip string)
- func FilesEqual(aPath, bPath string) error
- func GetStringMapKeys(theMap map[string]bool) []string
- func ImagesEqual(aPath, bPath string) error
- func MakeSaveableFileName(name string) string
- func RandStringBytesMaskImpr(n int) string
- func ReadImageFile(path string) (image.Image, error)
- func ReplaceStringsInSlice(vals []string, replacements map[string]string)
- func SetStringsInMap(vals []string, theMap map[string]bool)
- func StringInSlice(a string, list []string) bool
- func StringSlicesEqual(test []string, ans []string) bool
- func StripSharedItemIDPrefix(ID string) (string, bool)
- func UnzipDirectory(src string, dest string) ([]string, error)
- func WritePNGImageFile(pathPrefix string, img image.Image) error
- func ZipDirectory(dirPath string) ([]byte, error)
- type IDGen
Examples ¶
Constants ¶
const PrettyPrintIndentForJSON = " "
PrettyPrintIndentForJSON Pretty-print indenting of JSON
Any item that we share will have its ID prefixed with shared-. Not necessarily as stored in S3 because it may sit in a known shared directory, but when the API sends out a shared object, it must be prefixed this way
Variables ¶
This section is empty.
Functions ¶
func AddFilesToZip ¶
func FilesEqual ¶
func GetStringMapKeys ¶
REFACTOR: TODO: Make this more generic... and/or make an int version FAIL... this seems to not be compatible with ANYTHING??? func GetStringMapKeys(theMap map[string]interface{}) []string {
func ImagesEqual ¶
func MakeSaveableFileName ¶
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 RandStringBytesMaskImpr ¶
func ReplaceStringsInSlice ¶
func SetStringsInMap ¶
See comments about making this generic... search for REFACTOR, TODO or utils.SetStringsInMap()
func StringInSlice ¶
func StringSlicesEqual ¶
func StripSharedItemIDPrefix ¶
StripSharedItemIDPrefix - Strips shared prefix and returns true if object was shared
func ZipDirectory ¶
ZipDirectory - zips a whole directory and its contents (NOT recursive!) See: https://golang.ir/pkg/archive/zip/#example_Writer