Sunday, October 16, 2016

Configuring for Go Programming in Windows OS



In this post, I share how to configure for the 'Go' so I can use the environment for helping the testing of me.  The way tester did her/his testing a decade back is still applicable in a way, say, but technology has evolved and changing every day.  Moving along with the technology and being smart and quick in testing is expected today.

In one such regard, configuring the 'Go' for setup can be confusing to a tester most times.  I share how to configure the Go setup. So a tester will be ready to make use of it to compile and run the libraries to boost the testing based on where the context needs it. This post illustrate how to configure the Go on Windows OS.

While I'm writing this post, the link is valid and available. I can download the Go's MSI file from this page. Following the installation instructions in installer and on successful installation, I need to configure and save the environment variables in Windows OS for 
  • GOROOT -- pointing the path where the Go is installed on the Windows OS
  • GOPATH -- pointing the path where workspace is setup for Go


For the workspace of Go, I need to make sure it has got three directories -- bin, src, and pkg under the root directory. Example, if the path is d:\go_workspace, then under the directory go_workspace three directories will be available i.e. bin, src and pkg.

I assume that Go is installed and configured as said till here. Now, open the command prompt and provide this command.
go version
Doing this, should be able to see the version of installed Go.  At this time of writing, I see as below.
C:\Users\Pc-Ravisuriya>go version
go version go1.7.1 windows/amd64
Get the sample program from the Git of Go by providing below command in the command prompt.
go get github.com/golang/example/hello
 Now I can execute the hello program from where I'm (but I have to provide the path of program file for running it) or I have to go for the folder where the hello.go program is available. In the above said workspace path example, it will be under, d:\go_workspace\src\github.com\golang\example\hello.

Going to this directory in command prompt and running below command, I will see,
d:\go_workspace\src\github.com\golang\example\hello>go run hello.go
Hello, Go examples!

No comments:

Post a Comment

Please, do write your comment on the read information. Thank you.