github.com/tumi8/quic-go@v0.37.4-tum/noninternal/utils/buffered_write_closer.go (about) 1 package utils 2 3 import ( 4 "bufio" 5 "io" 6 ) 7 8 type bufferedWriteCloser struct { 9 *bufio.Writer 10 io.Closer 11 } 12 13 // NewBufferedWriteCloser creates an io.WriteCloser from a bufio.Writer and an io.Closer 14 func NewBufferedWriteCloser(writer *bufio.Writer, closer io.Closer) io.WriteCloser { 15 return &bufferedWriteCloser{ 16 Writer: writer, 17 Closer: closer, 18 } 19 } 20 21 func (h bufferedWriteCloser) Close() error { 22 if err := h.Writer.Flush(); err != nil { 23 return err 24 } 25 return h.Closer.Close() 26 }