Build a program with AI
Direct a model to write idiomatic Go — and review the error handling it likes to skip.
A small Go program produced under your direction.
Go’s explicit-error idiom, the prompt that gets idiomatic code, and what to check.
Prerequisites
A coding assistant. Go installed to run it, or read along.
The idioms you must recognise
- Errors are values, returned explicitly and checked — not exceptions. Watch for a model dropping the err return.
- Code lives in a package; execution starts at func main() in package main.
- gofmt is non-negotiable — idiomatic Go is formatted Go.
The prompt
Write a Go program that reads a number from the command line and prints its square. Constraints:- package main with func main().- Parse the argument with strconv.Atoi and handle the error explicitly.- If the argument is missing or not a number, print a clear message and exit non-zero.- gofmt-clean, no unused imports. Output a single main.go and the command to run it.Review what it writes
Review rubric
Tutorial
Learn the basics directly
The Learn tab writes the program by hand. Come here to direct it.
Concepts covered · 1
More like this
Build a script with AI
The vibe-coder path for Python: the shape of a small program, the prompt, and the edge cases AI forgets.
Your first C++ program
C++ trades a little ceremony for a lot of speed and control. Write a first program, learn the compile-then-run cycle, and open it in /code.
Build a calculator
Most courses teach variables before you have anything to put in one. We are going to skip that pain. We build the calculator first; the concepts show up when the calculator demands them.
Liked this one?
Pass it on
Discussion
Be the first to ask
Your questions stay private with the team. We can pin answers to share with everyone.
Sign in to ask a question privately on this tutorial.
Sign inNo pinned answers yet for this tutorial.