github.com/puellanivis/breton@v0.2.16/lib/files/deadline_writer.go (about) 1 package files 2 3 import ( 4 "context" 5 "io" 6 ) 7 8 type deadlineWriter struct { 9 ctx context.Context 10 w io.Writer 11 } 12 13 func (w *deadlineWriter) Write(b []byte) (n int, err error) { 14 select { 15 case <-w.ctx.Done(): 16 return 0, w.ctx.Err() 17 default: 18 } 19 20 return w.w.Write(b) 21 }