Documentation ¶
Overview ¶
qp is similar to fluent/quip, but with a bit more magic.
Example ¶
n, err := qp.BuildMap(basicnode.Prototype.Any, 4, func(ma ipld.MapAssembler) { qp.MapEntry(ma, "some key", qp.String("some value")) qp.MapEntry(ma, "another key", qp.String("another value")) qp.MapEntry(ma, "nested map", qp.Map(2, func(ma ipld.MapAssembler) { qp.MapEntry(ma, "deeper entries", qp.String("deeper values")) qp.MapEntry(ma, "more deeper entries", qp.String("more deeper values")) })) qp.MapEntry(ma, "nested list", qp.List(2, func(la ipld.ListAssembler) { qp.ListEntry(la, qp.Int(1)) qp.ListEntry(la, qp.Int(2)) })) }) if err != nil { panic(err) } dagjson.Encoder(n, os.Stdout)
Output: { "some key": "some value", "another key": "another value", "nested map": { "deeper entries": "deeper values", "more deeper entries": "more deeper values" }, "nested list": [ 1, 2 ] }
Index ¶
- func BuildList(np ipld.NodePrototype, sizeHint int64, fn func(ipld.ListAssembler)) (_ ipld.Node, err error)
- func BuildMap(np ipld.NodePrototype, sizeHint int64, fn func(ipld.MapAssembler)) (_ ipld.Node, err error)
- func ListEntry(la ipld.ListAssembler, fn Assemble)
- func MapEntry(ma ipld.MapAssembler, k string, fn Assemble)
- type Assemble
- func Bool(b bool) Assemble
- func Bytes(p []byte) Assemble
- func Float(f float64) Assemble
- func Int(i int64) Assemble
- func Link(l ipld.Link) Assemble
- func List(sizeHint int64, fn func(ipld.ListAssembler)) Assemble
- func Map(sizeHint int64, fn func(ipld.MapAssembler)) Assemble
- func Node(n ipld.Node) Assemble
- func Null() Assemble
- func String(s string) Assemble
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.