Created
February 2, 2022 09:03
-
-
Save rueian/f5d9096d361152ffdbdb5f0dac75ff6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "bufio" | |
| func writing(buf *bufio.Writer, input <-chan []byte) (err error) { | |
| var data []byte | |
| var more = true | |
| for more && err == nil { | |
| select { | |
| case data, more = <-input: | |
| _, err = buf.Write(data) | |
| continue | |
| default: | |
| } | |
| if err = buf.Flush(); err == nil { | |
| data, more = <-input | |
| _, err = buf.Write(data) | |
| } | |
| } | |
| return err | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment