This content originally appeared on DEV Community and was authored by Neeraj Kumar
- First add the package main in your program:
package main
Every Go file must start with a package name statement. Packages provide code encapsulation and reuse. The name of the package here is main.
- After adding main package import “fmt” package in your program:
import(
"fmt"
)
Import the fmt package, which will be used to print text to the standard output in the main function.
- Now write the code in the main function to print hello world in Go language:
func main() {
fmt.Println("Hello World")
}
func main():
The main function is a special function that is the entry point of a Go program. The main function must be included in the main package. { and } denote the start and end of the main function.
fmt.Println(“Hello World”):
The Println function in the fmt package is used to print text to standard output.
This content originally appeared on DEV Community and was authored by Neeraj Kumar

Neeraj Kumar | Sciencx (2023-02-25T18:05:11+00:00) Hello World in Golang. Retrieved from https://www.scien.cx/2023/02/25/hello-world-in-golang/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.