Hello World! First Golang Program

Hello World! First Golang Program

Writing my first code in Go.

Hello Friends, Today we will understand and write our Golang code from scratch. We will go through the pre-requisites and later will go through the code.


The requirement for running GO.

For executing any go program, the following steps must be followed. We must have Go binaries installed on our machine. for that please follow the steps in the link


Writing Hello Go Example

Save the below code in the main.go file.

package main

import "fmt"

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

Running the code

Run the code by running the below command.

go run main.go

Screenshot 2022-07-03 at 1.50.34 PM.png

Understanding the program

  • package is used to tell which component it belongs to. for our example, it is in the main package.
  • import is used to import libraries in the golang. fmt is a go-provided library that helps to spit out output in the command line.
  • fmt.Println() is used to print statements in golang.

Thanks for reading. I hope this story was helpful.

If you are interested, check out my other articles.

you can also visit shubhamdeshmukh.com.

GitHub: github.com/sd2995/GoLang/tree/main/HelloWor..