2017-08-09 74 views
-1

我想在我的項目中使用IPFS,然後我在研究Go IPFS API。 於是,我寫了這個非常簡單的代碼:嘗試將文件發送到IPFS時出現「命令未找到」

package main 

import (
    "fmt" 
    "bytes" 
    sh "github.com/ipfs/go-ipfs-api" 
) 

func main() { 
    shell := sh.NewShell("https://ipfs.io") 

    bufferExample := bytes.NewBufferString("Hello IPFS Shell tests") 
    mhash, err := shell.AddNoPin(bufferExample) 

    if err != nil { 
     panic(err) // ends where 
    } 

    fmt.Println(mhash) 
} 

但我收到錯誤panic: add: command not found,我不明白爲什麼。我的電腦中已經有IPFS(例如,我可以運行deamon)。我還安裝了帶有開發依賴關係的Go IPFS庫。

如何解決?

回答

2

該錯誤與各種路徑無關。該程序正在運行,它的恐慌,因爲你要求它在一個錯誤的情況下:

mhash, err := shell.AddNoPin(bufferExample) 
if err != nil { 
    panic(err) // ends where 
} 

錯誤add: command not found是不能夠找到add命令(錯誤是http 404)系統的結果。

您是否在系統上安裝了IPFS命令?如果沒有,那麼在嘗試之後嘗試。

+0

是的,我已經安裝了IPFS命令。例如,我可以運行守護進程。 – Macabeus

相關問題