Hello World in Go/Golang

Viewed: 92 times

Every good things start with one print of Hello World.

Let's make opening by writing it and start making the world better place using go. 😉

Create a file main.go and add the code below:


// main.go

// every go file must start with package name
package main

// when we use libraries we need to import them
import "fmt"

// main function is the entry point of the program
func main() {
    // print hello world using fmt library
    fmt.Println("Hello World")
}

// output: Hello World
            

Run the program using command: go run main.go


$ go run main.go
Hello World
        

Congratulations!

You have successfully created your first Go program.

Keep learning and enjoy!