📝 Program: main.go
package main
import "fmt"
// 📘 Main function is the entry point of the program.
func main() {
// 🎯 Declaring an integer variable 'x' and assigning it a value of 5
var x int = 5
// 💡 Printing the value of x
fmt.Println("📌 The value of variable x is:", x)
}
📖 Explanation
| Line | Code | Description |
|---|---|---|
| 1 | package main |
Declares that this file belongs to the main package (entry point). |
| 3 | import "fmt" |
Imports the fmt package for formatted I/O. |
| 6 | func main() { |
Declares the main function, which Go looks for to run the program. |
| 8 | var x int = 5 |
Declares x as an int and initializes it with the value 5. |
| 11 | fmt.Println(...) |
Prints the value of x to the console. |
🚀 How to Run This Program
💻 Prerequisites
- Install Go from https://go.dev/dl
🛠️ Steps to Execute
- Create a file named
main.go:touch main.go - Paste the code above into
main.go. - Open terminal and navigate to the folder where
main.gois saved. - Run the program:
go run main.go - ✅ You’ll see the output:
📌 The value of variable x is: 5
🎨 Output (Styled)
🌈 Golang Variable Declaration Demo 🌈
-------------------------------------
📌 The value of variable x is: 5
🧠 Key Takeaways
var x int = 5shows explicit declaration with type and initialization.- You could also write it as
x := 5(type inferred) — but here we showcase the explicitvarsyntax.
Would you like a similar program with user input or a web interface as well?

I’m just commenting to make you understand what a magnificent experience my wife’s girl undergone checking your web site. She realized such a lot of pieces, not to mention what it is like to have a marvelous teaching style to make other individuals without hassle know a number of grueling subject matter. You undoubtedly did more than my desires. Many thanks for presenting the effective, trustworthy, revealing and also fun guidance on your topic to Julie.
Turkey historical tours Turkey tours packed with value! Affordable prices without compromising quality or experience. https://www.tapascenter.com//?p=7632
It is really a great and useful piece of info. I’m glad that you shared this useful information with us. Please keep us up to date like this. Thanks for sharing.
Alright mate, 7gbet’s got a decent selection. Been having a bit of a punt there myself. Nothing too crazy mind you, just a bit of fun. Worth a look if you’re after a new spot. Check it out here: 7gbet