By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Create a file named main.go inside your penny folder and type exactly this. Do not copy it: type it. The point of the first lesson is that every character becomes familiar.
package main
import "fmt"
func main() {
fmt.Println("Hello, Penny!")
}go run .If the terminal printed Hello, Penny!, you have already written, compiled and run a program. Everything else in this course is more of the same, in larger pieces.
| Line | Plain English | Rules to remember |
|---|---|---|
package main | This file belongs to the program's main package. | An executable program uses package main. It is always the first line. |
import "fmt" | I want to use the formatted input/output package. | Imports come after the package line. Unused imports are an error. |
func main() { | Here is the function where execution starts. | The name is lowercase main, with no arguments and no return value. |
fmt.Println(...) | Call the Println function from fmt. | Package name, a dot, then the function name. |
} | Close the function block. | Every opening curly brace needs a closing one. |
Add a second line inside main, save, and run again. Notice that the statements run in the order you write them.
package main
import "fmt"
func main() {
fmt.Println("Hello, Penny!")
fmt.Println("Ready to track some expenses.")
}fmt.Println("Hello, Penny!) fails with a message about a string literal. Strings need both quotes.func Main() compiles, but Go then says the program has no main function to start.import "fmt" without using fmt is an error, not a warning. Go refuses to build code with unused imports.Change the two messages to say who you are and what you are building. Add a third fmt.Println line that prints a number: try fmt.Println(3 + 4). Then answer this before running it: what do you expect to see, and will it include quotes?
Key takeaways
A complete program has package main, its imports, and func main.
go run . compiles and runs the module in the current folder.
Statements run top to bottom, one at a time.
Go is case-sensitive, requires both quotes on a string, and rejects unused imports.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.