req := commands.NewRequest(context.Background(), "version", "") respChan := make(chan *commands.Response, 1) go func() { resp, err := req.Send(ipfsDaemonAddr) if err != nil { fmt.Printf("error sending request: %v\n", err) } respChan <- resp }() resp := <-respChan fmt.Printf("Version: %s\n", resp.Output)
req := commands.NewRequest(context.Background(), "add", "") req.Option("quiet", true) req.FileArg("myfile.txt") resp, err := req.Send(ipfsDaemonAddr) if err != nil { fmt.Printf("error sending request: %v\n", err) } fmt.Printf("Hash: %s\n", resp.Output)This example creates a new request to the IPFS daemon to add a file called "myfile.txt" to the IPFS network. The "quiet" option is set on the request to suppress output. The Send function is called on the request to send it to the IPFS daemon. The response is then retrieved and the resulting hash is printed to the console.