package main import ( "io" ) type CountWriter struct { Writer io.Writer Count int64 } func (cw *CountWriter) Write(p []byte) (n int, err error) { n, err = cw.Writer.Write(p) cw.Count += int64(n) return n, err }