Go Dev Environments
Here I am listing down some initial environment setup for Go:
Install:
Go is available in a wide range of OS types. To install the go environment, here is the marg, https://golang.org/doc/install
GOPATH:
This is a directory outside of GOROOT. It mainly contains the source for the project and their binaries. Here go keeps all external packages we use in the project as well. We can use multiple GOPATHs. This can be an accessible folder on our computer. for example,
In mac,
we can create a folder called go and export it like (in the .bash_profile):
export GOPATH={a valid folder path}
export PATH=$PATH:$GOPATH/bin
do not forget to resource the .bash_profile
In Windows:
To Run:
To initiate I am writing a very simple hello world code in visual studio code.
There are few extensions for go are available in vs code.
Package:
When you have multiple files under main, and you want to access other function from another file which shares the common package, that time, run the go files by
run go *.go
or
go build
Few reference Articles:
https://medium.com/rungo/everything-you-need-to-know-about-packages-in-go-b8bac62b74cc