Golang quick reference: Hello World
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}package main:
Every Go program starts with a package declaration. The main package is the entry point for the Go compiler.
import "fmt":
This imports the "fmt" package, which provides functions for formatted I/O operations.
func main() {:
The main function is where our program starts executing. Every Go program must have a main function in the main package.
fmt.Println("Hello World!"):
This calls the Println function from the "fmt" package to print "Hello World!" to the console.
Run your program by typing go run <filename>.go. Happy coding!
Get Rahul Sid Patil’s stories in your inbox
Join Medium for free to get updates from this writer.
Try out this code on Go playground: https://go.dev/play/p/SDx5_QNEaoO
What is Go playground
Go playground is an excellent interactive tool to try out and learn Go programming. The good thing is it runs inside your web browser !!
Happy coding!!
Note: This article is part of my Golang: Quick Reference series for budding gophers.
Thank you for being a part of the community
Before you go:
- Be sure to clap and follow the writer ️👏️️
- Follow us: X | LinkedIn | YouTube | Newsletter | Podcast
- Check out CoFeed, the smart way to stay up-to-date with the latest in tech 🧪
- Start your own free AI-powered blog on Differ 🚀
- Join our content creators community on Discord 🧑🏻💻
- For more content, visit plainenglish.io + stackademic.com









