• Stars
    star
    47
  • Rank 583,254 (Top 12 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Golang counters for readers/writers

Datacounter

Golang counters for readers/writers.

Build Status GoDoc

Examples

ReaderCounter

buf := bytes.Buffer{}
buf.Write(data)
counter := datacounter.NewReaderCounter(&buf)

io.Copy(ioutil.Discard, counter)
if counter.Count() != dataLen {
	t.Fatalf("count mismatch len of test data: %d != %d", counter.Count(), len(data))
}

WriterCounter

buf := bytes.Buffer{}
counter := datacounter.NewWriterCounter(&buf)

counter.Write(data)
if counter.Count() != dataLen {
	t.Fatalf("count mismatch len of test data: %d != %d", counter.Count(), len(data))
}

http.ResponseWriter Counter

handler := func(w http.ResponseWriter, r *http.Request) {
	w.Write(data)
}

req, err := http.NewRequest("GET", "http://example.com/foo", nil)
if err != nil {
	t.Fatal(err)
}

w := httptest.NewRecorder()
counter := datacounter.NewResponseWriterCounter(w)

handler(counter, req)
if counter.Count() != dataLen {
	t.Fatalf("count mismatch len of test data: %d != %d", counter.Count(), len(data))
}

More Repositories

1

jsonf

Console JSON formatter with query feature
Go
65
star
2

easysort

Easy sort in Go
Go
44
star
3

mapstore

Multicore optimized in-memory data store in Go
Go
22
star
4

octobus

Fast remote command executor over SSH
Go
18
star
5

bankgo

Simple two app project represents simplest bank in the world
HTML
14
star
6

cliconfig

Urfave Cli flags setup from config struct fields
Go
10
star
7

goaero

Go client library for Aerospike Database
Go
9
star
8

rabbitmq-graphite-tool

Send metrics to Graphite over RabbitMQ with internal msg rates
Go
7
star
9

fastrand

Fast random generator (6ns) without state
Go
7
star
10

metasocks

Multi Tor Socks Proxy on Go lang
Go
7
star
11

playhub

Java
6
star
12

httplog

HTTP Logger
Go
6
star
13

opencapture

Cross platform video and audio capture library
Objective-C
4
star
14

jcopybook

Copybook marshal/unmarshal for Java
Java
4
star
15

uniqbloom

Command line filter repeated lines
Go
3
star
16

golang-chan-bench

Simple Golang Channel Benchmark
Go
2
star
17

logdb

Append only embedded binary database on pure Go
Go
2
star
18

nsq-simpletcp

Text stream publish to NSQ
Go
2
star
19

happybot

Slack bot for expanding go playground and wiki links
Go
2
star
20

vagrant-kubernetes

Lightweight local Kubernetes cluster with Vagrant
Shell
2
star
21

cockroach_bench

Go
1
star
22

utpbench

UTP protocol network benchmark in Go
Go
1
star
23

bin4j

Fast Binary Parsing Java Framework
Java
1
star
24

yandexmusicnative

Yandex Music (Яндекс Музыка) Native Client
HTML
1
star
25

dbmux

Database smart query routing proxy
1
star
26

rabbitmq-simpletcp

Text stream TCP daemon for publishing lines to RabbitMQ exchange
Go
1
star
27

slackhistorybot

Slack History Bot
Go
1
star
28

UltraFastBERT

The repository for the code of the UltraFastBERT paper
Python
1
star
29

pongoc

Pongo2 Cli Compiler
Go
1
star
30

poehali

Console client for JetBrains Poehali MMORPG
Python
1
star
31

poboco

Free Music Service
JavaScript
1
star
32

gatsby-status-dashboard

JavaScript
1
star
33

msgbatch

Go lang msgpack batch data library
Go
1
star
34

SubIndustryCorrelation

Jupyter Notebook
1
star
35

energetic-lime

CSS
1
star