Exemplo n.º 1
0
func init() {
	// by default, always encode things as cbor
	defaultCodec = string(mc.HeaderPath(mccbor.Header))
	muxCodec = mcmux.MuxMulticodec([]mc.Multicodec{
		mccbor.Multicodec(),
		jsonMulticodec(),
		pb.Multicodec(),
	}, selectCodec)
}
Exemplo n.º 2
0
import (
	"flag"
	"io/ioutil"
	"os"

	ipld "github.com/ipfs/go-ipld"
	coding "github.com/ipfs/go-ipld/coding"
	pb "github.com/ipfs/go-ipld/coding/pb"
	mc "github.com/jbenet/go-multicodec"
)

var codecs []mc.Multicodec = []mc.Multicodec{
	coding.CborMulticodec(),
	coding.JsonMulticodec(),
	pb.Multicodec(),
}

func codecByName(name string) mc.Multicodec {
	for _, c := range codecs {
		if name == string(mc.HeaderPath(c.Header())) {
			return c
		}
	}
	return nil
}

func main() {
	infile := flag.String("i", "", "Input file")
	outfile := flag.String("o", "", "Output file")
	codecid := flag.String("c", "", "Multicodec to use")