TutorialsPreview
LearnDeepReferenceCheatsheetBuild with AI
Build with AIBuildbeginner8 min

Build a program with AI

Direct a model to write idiomatic Go — and review the error handling it likes to skip.

You will build

A small Go program produced under your direction.

You will learn

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.
Paste into your assistant

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

M
Build·beginner·12 min

Make a page respond: a click counter

A page becomes alive the moment JavaScript listens for an event and changes the page in response. Build a counter, then open it in /code.

B
Build·beginner·9 min

Build interaction with AI

The vibe-coder path for JS events: the event→state→render loop you must hold in your head, the prompt, and the review.

B
Build·beginner·8 min

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.

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 in

No pinned answers yet for this tutorial.