Go Basics
Print a message from main.
Go
package main
import "fmt"
func main() {
name := "Ada"
fmt.Println("Hello,", name)
}Output
Hello, Ada
Explanation
A runnable Go program uses package main and a main function. Import fmt for formatted input and output.
Explore the dry run
Guided walkthroughReady
1
package main2
import "fmt"3
func main() {4
name := "Ada"5
fmt.Println("Hello,", name)6
}Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Declare name with inferred string type. | name = "Ada" | — | |
| Print the greeting and name with a space. | name = "Ada" | Hello, Ada |