forked from cerc-io/ipld-eth-server
85 lines
2.6 KiB
Markdown
85 lines
2.6 KiB
Markdown
# go-multicodec
|
|
|
|
[](http://ipn.io)
|
|
[](https://github.com/multiformats/multiformats)
|
|
[](https://webchat.freenode.net/?channels=%23ipfs)
|
|
[](https://github.com/RichardLitt/standard-readme)
|
|
[](https://travis-ci.org/multiformats/go-multicodec)
|
|
[](https://codecov.io/github/multiformats/go-multicodec?branch=master)
|
|
[](https://godoc.org/github.com/multiformats/go-multicodec)
|
|
|
|
> [multicodec](https://github.com/multiformats/multicodec) implementation in Go.
|
|
|
|
### Supported codecs
|
|
|
|
- `/cbor`
|
|
- `/json`
|
|
- `/msgio`
|
|
- `/msgpack`
|
|
- `/protobuf`
|
|
|
|
## Table of Contents
|
|
|
|
- [Install](#install)
|
|
- [Usage](#usage)
|
|
- [Maintainers](#maintainers)
|
|
- [Contribute](#contribute)
|
|
- [License](#license)
|
|
|
|
## Install
|
|
|
|
```sh
|
|
go get github.com/multiformats/go-multicodec
|
|
```
|
|
|
|
## Usage
|
|
|
|
Look at the Godocs:
|
|
|
|
- https://godoc.org/github.com/multiformats/go-multicodec
|
|
|
|
```go
|
|
import (
|
|
"os"
|
|
"io"
|
|
|
|
cbor "github.com/multiformats/go-multicodec/cbor"
|
|
json "github.com/multiformats/go-multicodec/json"
|
|
)
|
|
|
|
func main() {
|
|
dec := cbor.Multicodec().Decoder(os.Stdin)
|
|
enc := json.Multicodec(false).Encoder(os.Stdout)
|
|
|
|
for {
|
|
var item interface{}
|
|
|
|
if err := dec.Decode(&item); err == io.EOF {
|
|
break
|
|
} else if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
if err := enc.Encode(&item); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Maintainers
|
|
|
|
Captain: [@jbenet](https://github.com/jbenet).
|
|
|
|
## Contribute
|
|
|
|
Contributions welcome. Please check out [the issues](https://github.com/multiformats/go-multicodec/issues).
|
|
|
|
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
|
|
|
|
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
|
|
|
## License
|
|
|
|
[MIT](LICENSE) © 2014 Juan Batiz-Benet
|