For a better understanding of this example, we always recommend you to learn the basic topics of Golang programming listed below:
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.
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.
STEP 1: Import the package fmt
STEP 2: Start function main()
STEP 3: Display the text "Hello World!" first using fmt.println()
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
Hello World