Debian Codegraph @

discard.go

raw symbols SCIP
1 package buffer
2
3 import (
4 "encoding/gob"
5 "io"
6 "io/ioutil"
7 "math"
8 )
9
10 type discard struct{}
11
12 // Discard is a Buffer which writes to ioutil.Discard and read's return 0, io.EOF.
13 // All of its methods are concurrent safe.
14 var Discard Buffer = discard{}
15
16 func (buf discard) Len() int64 {
17 return 0
18 }
19
20 func (buf discard) Cap() int64 {
21 return math.MaxInt64
22 }
23
24 func (buf discard) Reset() {}
25
26 func (buf discard) Read(p []byte) (n int, err error) {
27 return 0, io.EOF
28 }
29
30 func (buf discard) Write(p []byte) (int, error) {
31 return ioutil.Discard.Write(p)
32 }
33
34 func init() {
35 gob.Register(&discard{})
36 }