Run your first Go main.go program
Write the first file
Create a new folder for your practice, then save the following as main.go using a plain-text editor. The file extension matters; check that your editor did not save it as main.go.txt. The next lesson explains each line.
Run from the folder containing the file
You should see Hello, Go! on a new line. For this single-file example using only the standard library, a module file is not needed. go run builds and runs the program without leaving a named executable in the practice directory.
Change the message
package main
import "fmt"
func main() { fmt.Println("I am learning Go")}Save before running again. If the terminal says the file cannot be found, check the current directory and filename. If the old message appears, check whether you saved the correct file.
Try it locally
Change the message to Welcome, Ada and run main.go again. Compare the output exactly.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Getting Started 04: Run your first Go main.go program
Check the lesson objective before moving on.
Which command runs the example file?
If the terminal prints the old message after an edit, what should you check?