codec/raw: implement the raw codec
It's small, it's simple, and it's already widely used as part of unixfs. So there's no reason it shouldn't be part of go-ipld-prime. The codec is tiny, but has three noteworthy parts: the Encode and Decode funcs, the cidlink multicodec registration, and the Bytes method shortcut. Each of these has its own dedicated regression test. I'm also using this commit to showcase the use of quicktest instead of go-wish. The result is extremely similar, but with less dot-import magic. For example, if I remove the Bytes shortcut in Decode: --- FAIL: TestDecodeBuffer (0.00s) codec_test.go:115: error: got non-nil error got: e"could not decode raw node: must not call Read" stack: /home/mvdan/src/ipld/codec/raw/codec_test.go:115 qt.Assert(t, err, qt.IsNil)
Showing
codec/raw/codec.go
0 → 100644
codec/raw/codec_test.go
0 → 100644
... | ... | @@ -3,6 +3,7 @@ module github.com/ipld/go-ipld-prime |
go 1.14 | ||
require ( | ||
github.com/frankban/quicktest v1.11.3 | ||
github.com/ipfs/go-cid v0.0.4 | ||
github.com/minio/sha256-simd v0.1.1 // indirect | ||
github.com/mr-tron/base58 v1.1.3 // indirect | ||
... | ... |
Please register or sign in to comment