mirror of https://github.com/containrrr/watchtower
				
				
				
			Send mails that correspond to RFC2045 with a base64 line limit of 76 characters.
							parent
							
								
									28dff65282
								
							
						
					
					
						commit
						09f047ab8b
					
				@ -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…
					
					
				
		Reference in New Issue