MacOS编译ipfs

1、安装go等必须的软件

brew install go

2、设置gopaht环境变量

export gopath=PAHT_TO_GOPATH

#然后在gopath下创建下面的目录
PAHT_TO_GOPATH/src/github.com/ipfs/

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

3、下载源码

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

4、编译go-ipfs

cd go-ipfs
make

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

5、下载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

6、修改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)
}

7、编译gx及gx-go

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

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

9、编译ipfs

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

Comments are closed.