HOW TO SETUP GOLANG PROJECT

In this tutorial, i am assuming that you already have installed the Golang on your machine. If you are new for Golang and want to setup Go in your system, visit - http://www.webseekerz.com/blog/how-setup-golang-windows-7.html
If you want to setup on your linux machine, you will get to know with in this tutorial -

  1. If you already have installed the Golang, few variables must be set in your environment variables - i.e.
    export GOROOT=/usr/local/go
    export GOPATH=/usr/local/go/bin
  2. These paths helps us to use Go and access Go packages.
  3. Now we have to setup our custom project. So create a project folder, for example - golearning.
    mkdir /opt/golearning
  4. Now craeate a test file with main function. ex. example.go.
    Go to  - cd /opt/golearning then
    touch example.go
  5. Open the file in text editor and write the program.

    package main

    import "fmt"

     func main() {
         fmt.Println("Hello World")
     }

  6. Run the program i.e
    go run example.go

    Output - Hello World

    In next article. we'll learn how to create custom packages in Golang.

Blog Category: