mirror of
https://github.com/ChronosX88/yans.git
synced 2024-11-09 23:21:01 +00:00
22 lines
400 B
Go
22 lines
400 B
Go
|
package stringutil
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"net/mail"
|
||
|
)
|
||
|
|
||
|
// JoinAddress formats a slice of Address structs such that they can be used in a To or Cc header.
|
||
|
func JoinAddress(addrs []mail.Address) string {
|
||
|
if len(addrs) == 0 {
|
||
|
return ""
|
||
|
}
|
||
|
buf := &bytes.Buffer{}
|
||
|
for i, a := range addrs {
|
||
|
if i > 0 {
|
||
|
_, _ = buf.WriteString(", ")
|
||
|
}
|
||
|
_, _ = buf.WriteString(a.String())
|
||
|
}
|
||
|
return buf.String()
|
||
|
}
|