Simple Hello World Program in Golang for beginners


Setup:

Firstly make sure you have done Golang setup as per https://go.dev/doc/install.
You can start programming once you could run go version command.


Program:

Create a file named hello.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}
  • Package main is a way to group functions inside the directory.
  • fmt package has methods for console printing and text formatting.
  • main is default method which runs and prints Hello World.

Run program by:

go run hello.go


You can build it and run by:

go build hello.go

./hello

Don’t watch the clock; do what it does.
Keep going! :thumbs_up: