Building a custom fork of Go¶
Note
For your reference, here is the relevant offical document: Installing Go from source.
Lantern requires a custom fork of Go, which doesn’t provide pre-built binary files, so we’ll have to compile it by ourselves.
Install Go compiler binaries¶
The Go tool chain is written in Go. To build it, you need a Go compiler installed.
Launch a MinGW64 shell, which you can find at
C:\msys64\mingw64.exe, if you haven’t yet.Change the current directory to your home directory:
cd $HOME
According to the offical document, you can use a binary release as a bootstrap tool chain, see the downloads page. However, the link seems to be blocked, so let’s build the bootstrap tool chain from source instead.
First, download the source by:
wget https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz
And a compressed file of 10.79 MB will be downloaded.
Note
If the download fails, try the following command:
wget http://ulantern.readthedocs.io/en/latest/_downloads/go1.4-bootstrap-20170531.tar.gz
Next, unpack it. This is going to take several seconds:
mkdir Go1.4/ && tar -zxvf go1.4-bootstrap-20170531.tar.gz -C Go1.4/ --strip-components=1
Finally,
cdto thesrcsubdirectory and runmake.bat. This would take a while:cd Go1.4/src/ ./make.bat
Now it’s return to the home directory:
cd $HOME
(Optional) Now you can delete the compressed file, if you want:
rm go1.4-bootstrap-20170531.tar.gz
Fetch the Go repository¶
Create a directory named
Lantern. It will be containing the repository (i.e. source code) of Go and Lantern:mkdir Lantern
Change directory to
Lantern:cd Lantern
Download the custom fork of Go from Github:
git clone https://github.com/getlantern/go.git cd go git checkout lantern
Note
When you see a multi-line line code block, run the command on each line one aftr one.
Install Go¶
Build the Go distribution:
cd src ./all.bat
all.batwould also run some tests after building Go. If you wish to skip the tests, run the following commands instead:cd src ./make.bat
Then, add the
bindirectory to$PATH:echo "# getlantern/go" >> ~/.bashrc echo "export GOROOT=$HOME/Lantern/go" >> ~/.bashrc echo "export PATH=$PATH:$GOROOT/bin" >> ~/.bashrc source ~/.bashrc
Go to the final step, Building Lantern.