mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-05-28 09:25:37 +02:00
WIP: Since ID, works
This commit is contained in:
parent
ce9e9f3e0d
commit
4af9c07577
7 changed files with 153 additions and 33 deletions
util
15
util/util.go
15
util/util.go
|
@ -88,7 +88,20 @@ func RandomString(length int) string {
|
|||
return string(b)
|
||||
}
|
||||
|
||||
// DurationToHuman converts a duration to a human readable format
|
||||
// ValidRandomString returns true if the given string matches the format created by RandomString
|
||||
func ValidRandomString(s string, length int) bool {
|
||||
if len(s) != length {
|
||||
return false
|
||||
}
|
||||
for _, c := range strings.Split(s, "") {
|
||||
if !strings.Contains(randomStringCharset, c) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// DurationToHuman converts a duration to a human-readable format
|
||||
func DurationToHuman(d time.Duration) (str string) {
|
||||
if d == 0 {
|
||||
return "0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue