mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-17 06:57:40 +08:00
docs: replace outdated package paths described in rpc README (#10505)
Closes #10498
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
> IPFS CoreAPI implementation using HTTP API
|
||||
|
||||
This packages implements [`coreiface.CoreAPI`](https://pkg.go.dev/github.com/ipfs/boxo/coreiface#CoreAPI) over the HTTP API.
|
||||
This package implements [`coreiface.CoreAPI`](https://pkg.go.dev/github.com/ipfs/kubo/core/coreiface#CoreAPI) over the HTTP API.
|
||||
|
||||
## Documentation
|
||||
|
||||
@ -16,29 +16,33 @@ Pin file on your local IPFS node based on its CID:
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
path "github.com/ipfs/boxo/coreiface/path"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// "Connect" to local node
|
||||
node, err := rpc.NewLocalApi()
|
||||
if err != nil {
|
||||
fmt.Printf(err)
|
||||
return
|
||||
}
|
||||
// Pin a given file by its CID
|
||||
ctx := context.Background()
|
||||
cid := "bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku"
|
||||
p := path.New(cid)
|
||||
err = node.Pin().Add(ctx, p)
|
||||
if err != nil {
|
||||
fmt.Printf(err)
|
||||
return
|
||||
}
|
||||
return
|
||||
// "Connect" to local node
|
||||
node, err := rpc.NewLocalApi()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
// Pin a given file by its CID
|
||||
ctx := context.Background()
|
||||
c, err := cid.Decode("bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
p := path.FromCid(c)
|
||||
err = node.Pin().Add(ctx, p)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user