Golang Program to print “Hello World”


March 12, 2022, Learn eTutorial
1701

For a better understanding of this example, we always recommend you to learn the basic topics of Golang programming listed below:

How to display “Hello World!”

Here we are explaining how to write a Go program to display “Hello World!” on the screen. We can use the built-in function fmt.println() to print the string "Hello World". This function is defined under the fmt package and it helps to write standard output. In order to use these functions, we need to import the “fmt” package.

How to display “Hello World!” is implemented in Go Program

We are using fmt.println() function for printing the string to the output screen. Given below are the steps which are used in the Go program to print the string. 

ALGORITHM

STEP 1: Import the package fmt

STEP 2: Start function main()

STEP 3: Display the text "Hello World!" first using fmt.println()

Golang Source Code

                                          package main
import "fmt"

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

OUTPUT

Hello World