Course outline
Course / The terminal and the language

Run it, then build it

Lab

How to fetch and submit this lab

Once: install the tool and connect your account.

curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon login

Each lab: download it, edit the file named in the instructions, then submit.

gonomicon fetch week-1/07-02-build-the-executable
cd 07-02-build-the-executable
gonomicon submit

Go installed? gonomicon test runs the visible test on your computer first. Submitting also runs hidden checks on our server.

Goal

Write a program that prints exactly:

Learning Go, one program at a time!

This lab checks something extra: that go run and a binary built with go build produce identical output, since they're compiling and running the exact same source file.

Where to write it

Edit main.go.

Checking your work

go run .
go build -o app .
./app

Both should print the same line. Then run the test:

go test ./...

Run it

gonomicon fetch week-1/07-02-build-the-executable
cd 07-02-build-the-executable
gonomicon test
gonomicon submit

Hints

  1. go run compiles and runs in one step; go build only compiles, producing a file you run yourself.
  2. Both commands compile the exact same source, so their output should match exactly.

Something wrong with this lesson? Report a problem