📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. Introduction
Golang, commonly known as Go, is an open-source programming language that makes it easy to build simple, reliable, and efficient software. In this tutorial, we will write a very simple "Hello, World!" program in the Go programming language.
2. Program Overview
The primary objective is to create a Golang program that gracefully outputs the message "Hello, World!" to the console.
3. Code Program
// Declare the main package: the entry point for the application.
package main
// Import the fmt package for formatted I/O operations.
import "fmt"
// main function: the primary function that will be executed when the program runs.
func main() {
// Use the Println function from fmt package to print "Hello, World!" to the console.
fmt.Println("Hello, World!")
}
Output:
Hello, World!
4. Step By Step Explanation
1. Package Declaration:
Every Go program starts with a package declaration. Here, we've declared the main package, signaling that our program is a standalone executable.
// Declare the main package: the entry point for the application.
package main
2. Import Statement:
By importing the fmt package, we gain access to various formatted I/O operations.
// Import the fmt package for formatted I/O operations.
import "fmt"
3. Main Function:
The main function serves as our program's entry point. When the program is executed, it starts by running this function.
// main function: the primary function that will be executed when the program runs.
func main() {
// Use the Println function from fmt package to print "Hello, World!" to the console.
fmt.Println("Hello, World!")
}
4. Print Function:
Inside our main function, we've called the fmt.Println() method. This function prints the string passed to it followed by a newline. In our case, it prints "Hello, World!" to the console.
// Use the Println function from fmt package to print "Hello, World!" to the console.
fmt.Println("Hello, World!")
Comments
Post a Comment
Leave Comment