- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
type cntWriter struct {
count int
w io.Writer
}
func (cw *cntWriter) write(s string) {
if cw.count >= 1024 {
return
}
n := write(s)
cw.count += n
}
func (cw *cntWriter) written() int { return cw.count }
func main() {
cw := &cntWriter{}
cw.write(“one”)
cw.write(“two”)
cw.write(“three”)
fmt.Printf(“Written %d bytes\n”, cw.count)
}
LispGovno 03.11.2015 10:47 # +1
Abbath 03.11.2015 11:30 # +6
guest 03.11.2015 13:16 # 0
guest 03.11.2015 14:46 # 0