package main import ( "crypto/sha256" "encoding/base64" "os" "path/filepath" ) // URLToBase64 returns the base64 encoding of the URL parameter func URLToBase64(URL string) string { h := sha256.New() h.Write([]byte(URL)) return base64.URLEncoding.EncodeToString(h.Sum(nil)) } // Base64ToURL returns the string decoded base64 value func Base64ToURL(value string) string { decoded, _ := base64.URLEncoding.DecodeString(value) return string(decoded) } // FileExists returns true if path exists func FileExists(path string) bool { _, err := os.Stat(path) return !os.IsNotExist(err) } // GetStreamDirPath returns filepath.Join(".", "streams") func GetStreamDirPath() string { return filepath.Join(".", "streams") } // StreamStorePathExists returns FileExists(GetStreamDirPath()) func StreamStorePathExists() bool { return FileExists(GetStreamDirPath()) }