mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
0592aac95c
Changes: 44306b6a1d...318312a373
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
16 lines
322 B
Go
16 lines
322 B
Go
package internal
|
|
|
|
import "errors"
|
|
|
|
// DiscardZeroes makes sure that all written bytes are zero
|
|
// before discarding them.
|
|
type DiscardZeroes struct{}
|
|
|
|
func (DiscardZeroes) Write(p []byte) (int, error) {
|
|
for _, b := range p {
|
|
if b != 0 {
|
|
return 0, errors.New("encountered non-zero byte")
|
|
}
|
|
}
|
|
return len(p), nil
|
|
}
|