Gangmax Blog

自由之思想,独立之精神

Go, IPFS and Ipfs-update

| Comments

From here and here.

Install golang

The first thing is to install golang. Here I use the downloading package to install. This will make sure you will install the latest version of golang. You can also choose the “apt-get install golang-go” command but I’m not sure if it’s the latest version.

Download the latest golang package file from here. Then run the following command to extract the files to your “/usr/local/go” directory.

1
2
3
# "tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz"
# In my case the file is "go1.11.2.linux-amd64.tar.gz".
tar -C /usr/local -xzf go1.11.2.linux-amd64.tar.gz

Make sure you have the following lines in your “~/.bashrc” or “~/.zshrc” file.

1
2
3
4
5
6
# Set your "$GOPATH" environment variable.
export GOPATH=$HOME/lang/go
# Add the "/usr/local/go/bin" directory to your "$PATH" environment variable.
export PATH=$PATH:/usr/local/go/bin
# Add "$GOPATH/bin" to make sure the binary under it can be executed.
export PATH=$PATH:$GOPATH/bin

Install “ipfs-update” and “ipfs”

“ipfs-update” is a command-line tool to install and upgrade the “ipfs” binary.

1
2
3
4
5
6
7
8
9
10
# Install "ipfs-update".
go get -u github.com/ipfs/ipfs-update
# List all the available "ipfs" versions.
ipfs-update versions
# Install the latest version.
ipfs-update install latest
# Initialize "ipfs".
ipfs init
# Open "README".
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

gx

gx” is a pacakge mananger for “golang” based on “ipfs”.

1
2
3
4
5
6
7
8
# Install.
go get -u github.com/whyrusleeping/gx
# Go to a src directory with the "package.json" file.
cd $GOPATH/src/github.com/whyrusleeping/gx
# Install the dependencies.
gx install
# List the dependencies.
gx deps

Summary

  1. Download the “golang” package, extract it to “/usr/local” directory, add the “/usr/local/go/bin” to “$PATH”, as well as defining “$GOPATH” and adding “$GOPATH/bin” to “$PATH”, then “go” is ready to be used.

  2. Install “ipfs-update” package by the “go get -u github.com/ipfs/ipfs-update” command, then install “ipfs” by the “ipfs-update install latest”, run “ipfs init”, then “ipfs” is ready.

Comments