Golang under Cygwin

The current article I have to write by two reasons. First - the Go language developed by Google becoming popular little by little. Second - there is NO accurate information about how to setup Go under Cygwin.

Go also commonly referred to as Golang, is a open source programming language developed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. Designed primarily for systems programming, it is a compiled, statically typed language in the tradition of C and C++, with garbage collection, various safety features and CSP-style concurrent programming features added.”

To setup Golang under Cygwin you need a version of Go for Windows platform (6432-bit). You can download it from HERE. I used go1.5.3.windows-amd64.zip in time of writing.

Unzip the package into the $HOME/go directory of your Cygwin environment. You can chose the other directory name if you like.

Next add the environment variables to the .bash_profile file:

# Golang
export GOROOT="C:/cygwin64/home/UserName/go"
export PATH=$PATH:$HOME/go/bin
export GOPATH="C:/cygwin64/home/UserName/code/gowork"

Pay attention, Golang demands to have the full Windows style path not Cygwin path. Golang located in home go directory and my working directory for Go programming located in code/gowork. Correct your PATHs if something different from your location.

This documentation describes how to create the Hello World program and run it on your system.

If you have any experience, tips or suggestions write the comments below.

Thanks for your time.

comments powered by Disqus