DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Golang Notes


Install Go

For Linux, download go1.5.1.linux-amd64.tar.gz from Go homepage, extract it to folder "/usr/local/go". Add the following lines into ~/.zshenv:

GOROOT=/usr/local/go
PATH=$PATH:$GOROOT/bin

For Windows, download go1.8.3.windows-amd64.zip and extract to folder c:\apps*. Create a new folder packages under c:\apps\go1.8.3*. Add environment variable GOROOT=c:\apps\go1.8.3 and GOPATH=c:\apps\go1.8.3\packages. You can use Rapidee to modify these env variables.

Run go env to verify the installation.

Install packages

Golang repo is blocked by GFW, such as 'https://go.googlesource.com/text/...', 'golang.org/x/...', etc. And go get can only use http proxy. So we have to install cow as the http proxy. First download a release (for me it's cow-win64-0.9.8.zip) and extract to C:\apps. Add the following lines to its rc.txt:

listen = http://127.0.0.1:7777
proxy = socks5://127.0.0.1:1080

Here we use a shadowsocks client as the parent proxy, while cow can use remote ss server directly.

Now run commands below to install a go packages (no need to modify git proxy configuration):

set HTTP_PROXY=http://localhost:7777
set HTTPS_PROXY=http://localhost:7777
go get -u github.com/monochromegane/the_platinum_searcher/

Note: Using socks5 proxy directly with netsh winhttp set according to Setting a proxy for Windows using the command-line not works.



Published

Feb 9, 2016

Last Updated

Feb 9, 2016

Category

Tech

Tags

  • golang 1
  • linux 158

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor