Wednesday, April 15, 2015

Day 2 - Creating a Go workspace

Creating a Go workspace was much more "head scratching" for me than I thought it would be.


There is this github folder thing in your workspace and the enviroment variables to set which I did not understand at the first glance. So here is what I googled and did to set up a workspace:

Create a simple empty Directory which is NOT the same as $GOROOT and point $GOPATH to it:



(How to set Environment variables in Windows: http://www.computerhope.com/issues/ch000549.htm) Type "set" in a cmd window to show them.

Create a subdirectory "src" in $GOPATH ( D:\goworkspace in my case )

Create the following path: $GOPATH\src\github.com\<yourgithubusername>

The github subdirectory is not mandatory but is considered best practice and will make things easier for you in the future if you want to store your source on github. You dont need to have a github account at this time, just use a username that you would be using later on.

Reference: http://golang.org/doc/code.html#Workspaces


The source directory for all my Go code is now:

D:\goworkspace\src\github.com\kimxilxyong

There are different opinions out there on the interwebs, but as far as I have googled it, it is recommended that you have only ONE workspace. That means all your own source and 3rd party source is all together in one workspace. I will adhere to this recommendation for now, but would be glad to read your opinions and/or arguments about this question.


No comments:

Post a Comment