Adding upstream version 1.2.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6a5b4a9666
commit
82a6c39bcf
24 changed files with 2727 additions and 0 deletions
36
discard.go
Normal file
36
discard.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package buffer
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
)
|
||||
|
||||
type discard struct{}
|
||||
|
||||
// Discard is a Buffer which writes to ioutil.Discard and read's return 0, io.EOF.
|
||||
// All of its methods are concurrent safe.
|
||||
var Discard Buffer = discard{}
|
||||
|
||||
func (buf discard) Len() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (buf discard) Cap() int64 {
|
||||
return math.MaxInt64
|
||||
}
|
||||
|
||||
func (buf discard) Reset() {}
|
||||
|
||||
func (buf discard) Read(p []byte) (n int, err error) {
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
func (buf discard) Write(p []byte) (int, error) {
|
||||
return ioutil.Discard.Write(p)
|
||||
}
|
||||
|
||||
func init() {
|
||||
gob.Register(&discard{})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue