mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-05-27 17:05:36 +02:00
Add firebase support
This commit is contained in:
parent
4677e724ee
commit
b145e693a5
7 changed files with 293 additions and 161 deletions
util
29
util/util.go
Normal file
29
util/util.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
randomStringCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
)
|
||||
|
||||
var (
|
||||
random = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
)
|
||||
|
||||
func FileExists(filename string) bool {
|
||||
stat, _ := os.Stat(filename)
|
||||
return stat != nil
|
||||
}
|
||||
|
||||
// RandomString returns a random string with a given length
|
||||
func RandomString(length int) string {
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
b[i] = randomStringCharset[random.Intn(len(randomStringCharset))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue