Pure Go implementation of sponge(1) in moreutils.
Warning
The buffer size and signal handling are roughly implemented. However, In most cases you don't need to worry.
sponge [-a] <file>: soak up all input from stdin and write it to <file>
sed '...' file | grep '...' | sponge [-a] file