编译(MacOS)

安装go等必须的软件

brew install go

设置gopaht环境变量

#建立gopath目录
#mkdir PAHT_TO_GOPATH

#导出环境变量
export gopath=PAHT_TO_GOPATH

#设置必要的代理信息
export http_proxy=xxxx:xx
export https_proxy=xxxx:xx
export no_proxy="localhost, 127.0.0.1, 192.168.99.100, 根据你自己的实际情况进行处理"

下载源码

mkdir PAHT_TO_GOPATH/src/github.com/ipfs/
cd PAHT_TO_GOPATH/src/github.com/ipfs/
git clone https://github.com/ipfs/go-ipfs.git

编译go-ipfs

cd go-ipfs
make

#会发现,gx无法获取所需的文件,原来是gx不会默认读取代理配置

下载gx代码

#然后在gopath下创建下面的目录
PAHT_TO_GOPATH/src/github.com/whyrusleeping/
cd PAHT_TO_GOPATH/src/github.com/whyrusleeping/
git clone https://github.com/whyrusleeping/gx.git
git clone https://github.com/whyrusleeping/gx-go.git
 
cd PAHT_TO_GOPATH/src/github.com/ipfs/
git clone https://github.com/ipfs/go-ipfs-api.git

修改go-ipfs-api代码,文件shell.go

func NewShell(url string) *Shell {
        c := &gohttp.Client{
                Transport: &gohttp.Transport{
                        Proxy: gohttp.ProxyFromEnvironment, //请增加这一行
                        DisableKeepAlives: true,
                },
        }
 
        return NewShellWithClient(url, c)
}

编译gx及gx-go

cd PAHT_TO_GOPATH/src/github.com/whyrusleeping/gx
make

cd PAHT_TO_GOPATH/src/github.com/whyrusleeping/gx-go
make

用编译好的go及go-gx替换PAHT_TO_GOPATH/src/github.com/ipfs/go-ipfs/bin目录下对应的文件

编译ipfs

cd PAHT_TO_GOPATH/src/github.com/ipfs/go-ipfs
make

完结

最后更新于