Short for Direct-RLP: A fast in-place RLP encoder
It requires Go 1.19 or newer.
go get github.com/qianbin/drlp
Number and string
var buf []byte
buf = drlp.AppendUint(buf, 10)
buf = drlp.AppendString(buf, []byte("hello drlp"))
fmt.Printf("%x\n", buf)
// Output: 0a8a68656c6c6f2064726c70
List
var buf []byte
buf = drlp.AppendString(buf, []byte("followed by a list"))
offset := len(buf)
buf = drlp.AppendString(buf, []byte("list content"))
buf = drlp.EndList(buf, offset)
fmt.Printf("%x\n", buf[offset:])
// Output: cd8c6c69737420636f6e74656e74
The MIT License