Adding and Getting CID of IPLD object GO


I cant seem to figure out how to add/get cid of an ipld object. I understand the example of encoding the data from the go-ipld-prime package, just can’t figure out how to add it and get the cid,

serial := strings.NewReader({"hey":"it works!","yes": true})

np := basicnode.Prototype.Any // Pick a stle for the in-memory data.
nb := np.NewBuilder()         // Create a builder.
dagjson.Decode(nb, serial)    // Hand the builder to decoding -- decoding will fill it in!
n := nb.Build()               // Call 'Build' to get the resulting Node.  (It's immutable!)

fmt.Printf("the data decoded was a %s kind\n", n.Kind())
fmt.Printf("the length of the node is %d\n", n.Length())

if i try ipfs.Dag().Add(ctx, SOMESTRING??) Add()wants the context and a node type. I cant add a node if this is the base node.

any thoughts?? im using go-ipfs-core as library.

1 Like

did you get it working?