Debian Codegraph @

README.md

raw symbols SCIP
1 nio
2 ==========
3
4 [![GoDoc](https://godoc.org/github.com/djherbis/nio?status.svg)](https://godoc.org/github.com/djherbis/nio)
5 [![Release](https://img.shields.io/github/release/djherbis/nio.svg)](https://github.com/djherbis/nio/releases/latest)
6 [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.txt)
7 [![Build Status](https://travis-ci.org/djherbis/nio.svg)](https://travis-ci.org/djherbis/nio)
8 [![Coverage Status](https://coveralls.io/repos/djherbis/nio/badge.svg?branch=master)](https://coveralls.io/r/djherbis/nio?branch=master)
9 [![Go Report Card](https://goreportcard.com/badge/github.com/djherbis/nio)](https://goreportcard.com/report/github.com/djherbis/nio)
10
11 Usage
12 -----
13
14 The Buffer interface:
15
16 ```go
17 type Buffer interface {
18 Len() int64
19 Cap() int64
20 io.ReadWriter
21 }
22
23 ```
24
25 nio's Copy method concurrently copies from an io.Reader to a supplied nio.Buffer,
26 then from the nio.Buffer to an io.Writer. This way, blocking writes don't slow the io.Reader.
27
28 ```go
29 import (
30 "github.com/djherbis/buffer"
31 "github.com/djherbis/nio"
32 )
33
34 buf := buffer.New(32*1024) // 32KB In memory Buffer
35 nio.Copy(w, r, buf) // Reads and Writes concurrently, buffering using buf.
36 ```
37
38 nio's Pipe method is a buffered version of io.Pipe
39 The writer return once its data has been written to the Buffer.
40 The reader returns with data off the Buffer.
41
42 ```go
43 import (
44 "gopkg.in/djherbis/buffer.v1"
45 "gopkg.in/djherbis/nio.v2"
46 )
47
48 buf := buffer.New(32*1024) // 32KB In memory Buffer
49 r, w := nio.Pipe(buf)
50 ```
51
52 Installation
53 ------------
54 ```sh
55 go get gopkg.in/djherbis/nio.v2
56 ```
57
58 For some pre-built buffers grab:
59 ```sh
60 go get gopkg.in/djherbis/buffer.v1
61 ```
62
63 Mentions
64 ------------
65 [GopherCon 2017: Peter Bourgon - Evolutionary Optimization with Go](https://www.youtube.com/watch?v=ha8gdZ27wMo&start=2077&end=2140)