Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

shoenig/counting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

counting

Count the number of bytes passing through an io.Writer

Go Report Card Build Status GoDoc NetflixOSS Lifecycle GitHub

Project Overview

Module gophers.dev/pkgs/counting provides a package with a utility function for counting the number of bytes that pass through an io.Writer.

Getting Started

The counting package can be installed by running

go get gophers.dev/pkgs/counting

Example Usage

f, _ := ioutil.TempFile("", "counting-")
counter := counting.NewCountingWriter(f)
compressor, _ := gzip.NewWriterLevel(counter, 9)
s := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") // 42 bytes
u, _ := compressor.Write(s)
compressor.Close()
c := counter.Written()
fmt.Println("uncompressed bytes written", u)
fmt.Println("compressed bytes written", c)

Contributing

The gophers.dev/pkgs/counting module is always improving with new features and error corrections. For contributing bug fixes and new features please file an issue.

License

The gophers.dev/pkgs/counting module is open source under the BSD-3-Clause license.

About

A counting io.Writer for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages