There are many posts asking for the way to compute CID of the specific file with command like ipfs add --offline --only-hash ./hello
or with a tool like ipfs-only-hash.
But, I couldn’t find the way to produce CID programmatically in golang. And I want to achieve it without running and accessing IPFS node.
Ideally, what I’m looking for is the example code snippet like the following:
f, err := os.Open("/path/to/file")
if err != nil {
return err
}
opts := {
offline,
onlyhash,
} // pseudo code
cid, err := ipfs.GetCID(f, opts)
if err != nil {
return err
}
fmt.Println(cid)
Thanks in advance.