Go source files and executable programs
Source versus executable
A .go file contains human-readable Go source. The compiler translates Go code, and the linker combines compiled code into an executable for a target operating system and architecture. The executable is the artifact the operating system can launch.
package main
import "fmt"
func main() { fmt.Println("Ready")}This source instructs the program to print Ready. Building it produces an executable, not another Go source file. In later lessons you will use go run for quick experiments and go build to keep an executable.
A changed source needs a new build
If you replace Ready with Done in the source, a previously built executable still contains the old program. Build again before running the new version. Renaming a text file to .exe does not compile it. Executables are generally target-specific, so a Linux binary is not automatically a Windows application.
Try it locally
Sketch the path from main.go to an executable to displayed output. If you edit the source after building, which artifact must be recreated?
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Getting Started 02: Go source files and executable programs
Check the lesson objective before moving on.
Which file is normally edited to change the program?
Why may a built Linux binary fail to launch on Windows?