From 72e18d4bfe5bafdfde159798aca3ccad98bb1c5f Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:10:01 -0700 Subject: [PATCH 1/2] Replace outdated package paths described in rpc README Closes #10498 --- client/rpc/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/rpc/README.md b/client/rpc/README.md index a020aa9da27..767416e8aef 100644 --- a/client/rpc/README.md +++ b/client/rpc/README.md @@ -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 @@ -20,7 +20,7 @@ import ( "fmt" "github.com/ipfs/kubo/client/rpc" - path "github.com/ipfs/boxo/coreiface/path" + "github.com/ipfs/boxo/path" ) func main() { @@ -39,6 +39,5 @@ func main() { fmt.Printf(err) return } - return } ``` From 74f4818b1450ac32a16df4ebf0dfd605fca4e488 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:35:23 -0700 Subject: [PATCH 2/2] Make example build correctly --- client/rpc/README.md | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/client/rpc/README.md b/client/rpc/README.md index 767416e8aef..d9744e5b6e3 100644 --- a/client/rpc/README.md +++ b/client/rpc/README.md @@ -16,28 +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" - "github.com/ipfs/boxo/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 - } + // "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 + } } ```