Go Hello World

Go Hello World

The best ways to start with any language is to write classic hello world program. So, to start with Golang write a program to print “Hello World !!!” on console.

Step 1: Write Hello World program

Create a file helloworld.go in any of the directory and open the file using any of your favorite text editor. Now, write below code to print “Hello world !!!”.

package main

import (
	"fmt"
)

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

Step 2: Run the program

Open command prompt inside the directory and use following command to run the program.

$ go run helloworld.go
Hello World !!!

Step 3: Create binary and execute it

To create executable binary, Golang provides go build command. Now use the command and execute the binary.

$ go build helloworld.go
$ ./helloworld
Hello World !!!

 

Stay tuned for more updates !

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *