Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




GO - INSTALLATION


To run Go Programs in you PC, you need to install Go first.


Installation of Go for Windows OS


Below are the steps to install Go on Windows OS :

  1. Goto the below link and download the latest version of Go.

    https://golang.org/doc/install
    Select the 'Windows' tab as shown in the below image
    Go-Installation01

  2. Once the 'go1.15.6.windows-amd64.msi' file is downloaded. Double click to open it.
    java_Collections

  3. After that the setup window will open. Now, you can start the Installation.

    java_Collections


    java_Collections


    java_Collections


    java_Collections


    java_Collections


    java_Collections

  4. Once Go is Installed, you can open the Command Prompt and Type 'go version'.

    java_Collections

    If the version is shown then Go is successfully installed in your system.

Installation of Go for MAC OS


Below are the steps to install Go on MAC OS :

  1. Goto the below link and download the latest version of Go.

    https://golang.org/doc/install

    java_Collections


    java_Collections


    java_Collections

  2. Once the 'go1.15.6.darwin-amd64.pkg' file is downloaded. Double click to open it.
    java_Collections

  3. Then follow the below steps to Install Go.

    java_Collections


    java_Collections


    java_Collections


    java_Collections


    java_Collections

  4. Once Go is Installed, you can open the Command Prompt and Type 'go version'.

    java_Collections

    If the version is shown then Go is successfully installed in your system.

Now, that we have Installed Go. Let us see how we can run a Go Program.


Running a Go Program in Windows OS


Let us write a Program that will print 'Hello World'.

  1. The first thing we will do is open 'Notepad' in Windows OS.
    java_Collections

  2. Once 'Notepad' is opened. You can type the lines of code there.

    And now, since we are trying to print 'Hello World'. Type the below lines.



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


    java_Collections

  3. Then save with '.go' extension. Say 'FirstProgram.go'.

    java_Collections

  4. Then run using the command 'go run FirstProgram.go'.

    java_Collections

And we are done.


Running a Go Program in MAC OS


Let us write a Program that will print 'Hello World'.

  1. The first thing we will do is open 'TextEdit' in MAC.
    java_Collections

  2. Once 'TextEdit' is opened. You can type the lines of code there.

    And now, since we are trying to print 'Hello World'. Type the below lines.



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




  3. java_Collections
  4. Then save with '.go' extension. Say 'FirstProgram.go'.

    java_Collections

  5. Then run using the command 'go run FirstProgram.go'.

And we are done.