How Do You Write a Hello World Program in Golang?

Problem scenario
You want to test out the Golang compiler.  You want to know how to write a basic Go program and run it.  What do you do?

Solution
Prerequisites

You must have the Golang compiler installed.  If you need help, see this posting.

Procedures
1.  Create a file called hw.go with the following five lines:

package main
import "fmt"
func main() {
    fmt.Println("This is a Hello World program!")
}

2.  Run the program by executing this command:  go run hw.go

Leave a comment

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