github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/ioutil/writeallto.go (about) 1 package ioutil 2 3 import "io" 4 5 // WriterTos implements something that can be represented as a list of io.WriterTo. 6 type WriterTos interface { 7 WriterTos() []io.WriterTo 8 } 9 10 // WriteAllTo calls WriteTo on all elements of the WriterTo slice and 11 // returns the total number of bytes written. 12 func WriteAllTo(out io.Writer, wts ...io.WriterTo) (tn int64, err error) { 13 for _, wt := range wts { 14 if wt == nil { 15 continue 16 } 17 var n int64 18 if n, err = wt.WriteTo(out); err != nil { 19 return tn, err 20 } 21 tn += n 22 } 23 return tn, nil 24 }