Skip to content

Instantly share code, notes, and snippets.

@vasa-develop
Created January 22, 2020 22:09
Show Gist options
  • Save vasa-develop/424cf99111333c72f83e617d68934951 to your computer and use it in GitHub Desktop.
Save vasa-develop/424cf99111333c72f83e617d68934951 to your computer and use it in GitHub Desktop.
SimpleAsWater Tutorial: Hands On IPLD Tutorial: PART 2
// Map the struct instance to the mapping
DocStoreMap[inputID] = employeeObject
// Converting the map into JSON object
entryJSON, err := json.Marshal(DocStoreMap)
if err != nil {
fmt.Println(err)
}
// Display the marshaled JSON object before sending it to IPFS
jsonStr := string(entryJSON)
fmt.Println("The JSON object of your document entry is:")
fmt.Println(jsonStr)
start := time.Now()
// Dag PUT operation which will return the CID for futher access or pinning etc.
cid, err := sh.DagPut(entryJSON, "json", "cbor")
elapsed := time.Since(start)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s", err)
os.Exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment