ipld-eth-server/vendor/github.com/libp2p/go-msgio
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00
..
.gxignore Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
.travis.yml Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
chan.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
codecov.yml Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
fuzz.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
go.mod Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
go.sum Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
LICENSE Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
limit.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
msgio.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
num.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
README.md Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
varint.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00

go-msgio - Message IO

codecov Travis CI Discourse posts

This is a simple package that helps read and write length-delimited slices. It's helpful for building wire protocols.

Usage

Reading

import "github.com/libp2p/go-msgio"
rdr := ... // some reader from a wire
mrdr := msgio.NewReader(rdr)

for {
  msg, err := mrdr.ReadMsg()
  if err != nil {
    return err
  }

  doSomething(msg)
}

Writing

import "github.com/libp2p/go-msgio"
wtr := genReader()
mwtr := msgio.NewWriter(wtr)

for {
  msg := genMessage()
  err := mwtr.WriteMsg(msg)
  if err != nil {
    return err
  }
}

Duplex

import "github.com/libp2p/go-msgio"
rw := genReadWriter()
mrw := msgio.NewReadWriter(rw)

for {
  msg, err := mrdr.ReadMsg()
  if err != nil {
    return err
  }

  // echo it back :)
  err = mwtr.WriteMsg(msg)
  if err != nil {
    return err
  }
}

Channels

import "github.com/libp2p/go-msgio"
rw := genReadWriter()
rch := msgio.NewReadChannel(rw)
wch := msgio.NewWriteChannel(rw)

for {
  msg, err := <-rch
  if err != nil {
    return err
  }

  // echo it back :)
  wch<- rw
}

The last gx published version of this module was: 0.0.6: QmcxL9MDzSU5Mj1GcWZD8CXkAFuJXjdbjotZ93o371bKSf