mirror of
https://codeberg.org/superseriousbusiness/gotosocial.git
synced 2024-12-27 19:38:26 +03:00
17 lines
322 B
Go
17 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
|
||
|
}
|