mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 22:20:12 +01:00
refactor: move actions into internal
This commit is contained in:
parent
62f603bb25
commit
a425bf1024
17 changed files with 26 additions and 29 deletions
24
pkg/notifications/util.go
Normal file
24
pkg/notifications/util.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package notifications
|
||||
|
||||
import "bytes"
|
||||
|
||||
// SplitSubN splits a string into a list of string with each having
|
||||
// a maximum number of characters n
|
||||
func SplitSubN(s string, n int) []string {
|
||||
sub := ""
|
||||
subs := []string{}
|
||||
|
||||
runes := bytes.Runes([]byte(s))
|
||||
l := len(runes)
|
||||
for i, r := range runes {
|
||||
sub = sub + string(r)
|
||||
if (i+1)%n == 0 {
|
||||
subs = append(subs, sub)
|
||||
sub = ""
|
||||
} else if (i + 1) == l {
|
||||
subs = append(subs, sub)
|
||||
}
|
||||
}
|
||||
|
||||
return subs
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue