github.com/primecitizens/pcz/std@v0.2.1/core/cerr/utils.go (about) 1 package cerr 2 3 // Writer is the error writer. 4 type Writer interface { 5 Write(s string) int 6 } 7 8 func WriteJoinE(w Writer, sep string, s ...E) int { 9 if len(s) == 0 { 10 return w.Write("") 11 } 12 13 n := s[0].WriteErr(w) 14 for _, e := range s[1:] { 15 n += w.Write(sep) + e.WriteErr(w) 16 } 17 18 return n 19 } 20 21 func WriteJoinS(w Writer, sep string, segments ...string) int { 22 if len(segments) == 0 { 23 return w.Write("") 24 } 25 26 n := w.Write(segments[0]) 27 for _, s := range segments[1:] { 28 n += w.Write(sep) + w.Write(s) 29 } 30 31 return n 32 }