Open In App

Hello World in Golang

Hello, World! is the first basic program in any programming language. Let’s write the first program in the Go Language using the following steps:

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

Example: 






// First Go program
package main
 
import "fmt";
 
// Main function
func main() {
 
    fmt.Println("!... Hello World ...!")
}

Output:

!... Hello World ...!

How to run Golang Program?

To run a Go program you need a Go compiler. In Go compiler, first you create a program and save your program with extension .go, for example, first.go. Now we run this first.go file in the go compiler using the following command, i.e:



$ go run first.go

Article Tags :