0
0
Goprogramming~15 mins

Writing first Go program - Mini Project: Build & Apply

Choose your learning style9 modes available
Writing first Go program
๐Ÿ“– Scenario: You want to create a simple Go program that prints a friendly greeting to the screen. This is like saying hello to a new friend using code.
๐ŸŽฏ Goal: Build a Go program that prints the message Hello, Go! to the console.
๐Ÿ“‹ What You'll Learn
Create a main package
Write a main function
Use fmt.Println to print the greeting
Print exactly Hello, Go!
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Every Go program starts with this structure. Printing messages helps you check your program works.
๐Ÿ’ผ Career
Knowing how to write a basic Go program is essential for software development jobs using Go.
Progress0 / 4 steps
1
Create the main package
Write package main at the top of your Go file to define the package.
Go
Need a hint?

Every Go program starts with a package declaration. Use package main for executable programs.

2
Add the main function
Write a func main() function below the package line to start your program.
Go
Need a hint?

The main function is where your program begins running.

3
Import the fmt package
Add an import statement to include the fmt package above the main function.
Go
Need a hint?

The fmt package lets you print text to the screen.

4
Print the greeting message
Inside the main function, write fmt.Println("Hello, Go!") to print the greeting.
Go
Need a hint?

Use fmt.Println with the exact text Hello, Go! inside quotes.