Exercises for learning Go and cloud native design
  • Go 95.3%
  • HTML 2.1%
  • Makefile 1.8%
  • Dockerfile 0.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
tamas646 97b7aacd2e
Some checks failed
Tests / Go exercises (push) Has been cancelled
Tests / Labs 02-06 in Kubernetes (push) Has been cancelled
fix(Makefile): Make generate and lab-test if $CURDIR contains spaces (#38)
Make the generate and lab-test scripts work if the current directory ($CURDIR) contains spaces.
2026-09-17 22:08:39 +02:00
.github/workflows chore(ci/cd): Run tests on all triggers 2026-09-17 14:28:02 +02:00
01-getting-started/01-hello-world Fix assert equals parameters (#16), fix #13 2023-12-14 23:31:01 +01:00
02-types fix(02-types/02-numbers): Fix README gen (#25) 2024-09-29 17:39:41 +02:00
03-variables Fix assert equals parameters (#16), fix #13 2023-12-14 23:31:01 +01:00
04-type-system Remove solution...:-) 2023-12-14 20:01:22 +01:00
06-switch 06-switch/02-grades: Fix a typo 2024-09-11 17:27:47 +02:00
07-loops feat: Add 07-loops/02-digits 2024-08-26 20:44:06 +02:00
08-arrays Fix: Fix 08-arrays/03-filtering-data tests 2024-08-27 14:06:28 +02:00
12-funcs Add closures exercise (#28) 2025-02-12 10:42:14 +01:00
15-pointers fix: Fix 15-pointers/02-new 2024-08-28 14:28:00 +02:00
19-structs feat: Add 19-structs/04-multidim-chess (#33) 2026-01-27 10:36:32 +01:00
20-goroutines Fix the concurrent primes exercise 2024-09-11 09:01:34 +02:00
21-channels Massive reorg 2024-09-02 14:15:03 +02:00
22-context doc(22/05-threadpool): Mention non-blocking Run() 2025-02-07 17:11:35 +01:00
23-misc 23-misc/01-scanning: Extend and clarify tasks (#12) 2024-01-29 16:43:30 +01:00
24-generics fix(24-generics/01-sorting): Fix tests 2025-01-15 10:39:18 +01:00
25-testing/01-testify feat: testing exercises (#36) 2026-01-27 10:37:04 +01:00
99-labs fix(99/01-setup): Bump gateway api crd version 2026-09-17 14:31:11 +02:00
env fix(Vagrantfile): Fix screen flickering 2026-09-03 16:51:24 +02:00
internals/lib fix: Remove __STUNDENT_ID override 2026-09-10 20:41:17 +02:00
.gitignore feat(99-labs): Test labs 02-06 automatically in Kubernetes 2026-09-10 18:42:49 +02:00
.golangci.yaml chore(CI/CD): Fix linter action error 2025-08-12 16:30:12 +02:00
AUTHORS Changes several configs and readmes (#5) 2023-09-04 19:15:19 +02:00
exercises-cli.go Improve template error reporting 2023-04-19 15:46:50 +02:00
go.mod chore(deps): Bump stretchr/testify to v1.12.1 2026-09-02 22:02:15 +02:00
go.sum chore(deps): Bump stretchr/testify to v1.12.1 2026-09-02 22:02:15 +02:00
LICENSE Initial commit 2023-02-16 17:34:29 +01:00
Makefile fix(Makefile): Make generate and lab-test if $CURDIR contains spaces (#38) 2026-09-17 22:08:39 +02:00
README.md doc: Update README and fix typos 2026-09-10 21:34:07 +02:00
STUDENT_ID Initial commit 2023-02-16 17:34:29 +01:00

Learning Go: Basic Go exercises

A series of basic Go exercises inspired from the Go: Bootcamp Course. Solving all exercises will not make you a Go ninja, but it should be enough to get you started.

Getting started

Change to the root of the git repo and generate the exercises:

echo <MY-STUDENT-ID> > STUDENT_ID
git add STUDENT_ID
git commit -m 'student id added'
make generate

Your student id should always be available in the file named STUDENT_ID in the main directory. You can override this by setting the id in the STUDENT_ID environment variable.

STUDENT_ID=<MY-STUDENT-ID> make generate

Solve the exercises

Write code

Go through the subdirectories, preferably in the same order as the file names, understand the exercise specified in the README.md file, and insert your solution into exercise.go near the placeholder.

Once done with the exercise in the directory <exercise-directory>, make sure to git-add and git-commit your solution.

git add <exercise-directory>/exercise.go
git commit -m 'solved <exercise-directory>'

You can divide your code into as many files as you like but don't forget to add each file to your git repo.

Test

At any point in time you can test your solutions as follows.

make test

Keep track of repo updates

Sometimes we update the main git repo to fix bugs or add new exercises. The below workflow shows how to update your local working copy from the master without overwriting your solutions already written.

Warning

Make sure to commit all your code into git: this will guarantee that you will never lose your solutions even if some of the below steps go wrong. You can also back up your git repo, but please make sure your solutions are kept private (a private GitHUb repo will do it).

With all local changes committed to git

If you have a clear git tree with all your changes committed, the below should update only the files that change in the master.

git pull --rebase

With local changes in the working directory

If you have uncommitted changes, follow the below steps.

  1. Store your changes temporarily.

    git stash
    
  2. Pull updates.

    git pull
    
  3. Restore your changes.

    git stash
    
  4. Optional: fix conflicts and re-run tests.

Add a new exercise

Add a new subdirectory and add the following files:

  • exercise.yaml: An exercise definition with a set of inputs, from which make generate will choose one by hashing on the student id to generate the exercise.
  • exercise.go: Placeholder for the solution.
  • .README.md: a README template with instructions.
  • .exercise_test.go: the test file to check your solutions.

If you add a new top-level directory, don't forget to include it in the EXERCISE_DIRS in the Makefile.

Each exercise directory is also listed in EXERCISES in the Makefile. That list is what make generate writes and what make clean removes, which keeps the two symmetric: a cleaned tree can always be regenerated. Add new exercises there too.

Then run make clean, this will add the placeholders for the exercise (these will be overwritten by make generate), add all files in the exercise dir to the git repo, and git-push.

Complete the labs

Labs tasks are located in the 99-labs folder. The labs give you hands-on development and deployment experience. You will learn how to build and containerize Go programs as well as how to run them in Kubernetes. Each lab contains a README that gives you context and specifies the lab exercises. The labs depend on each other, so it is recommended to complete them one after the other.

Each lab README walks you through the checks by hand, with kubectl and Minikube, which is how you are meant to work through them. Once you are done, make lab-test builds your container images, brings up a throwaway Kubernetes cluster, deploys your own manifests into it and runs every lab check against them, so you get a single pass or fail. It needs a container engine, and takes a few minutes to run.

make ci-test           # test exercises, then every lab
make lab-test          # test all the labs
LAB=05 make lab-test   # test only lab 05

Note

The CI tests are experimental: they pass in our tests, may not pass in yours. If the CI tests fail then that may not necessarily indicate a problem with your code. If you suspect the tests are wrong, please file a GitHub issue and copy-paste the test logs, we will investigate.

You can also run the checks against a cluster you already have, Minikube included. Build the images into that cluster, then point the tests at it with your usual KUBECONFIG:

cd 99-labs/ci
LABS_EXTERNAL_CLUSTER=1 LABS_SOURCE=$(git rev-parse --show-toplevel) go test ./ -run TestLab04 -v

See 99-labs/ci/README.md for the details.

Note

This repo is set up to automatically run the test suite at GitHub and report the result in a small status check: a green check mark if all tests (homework+labs) pass, a little red cross if not. This requires your student if in STUDENT_ID: make sure to commit and push it. Don't forget to commit all your lab solutions and manifests as well!

Clean up

Reset all generated files to the default placeholder. Warning: this will drop all your uncommitted local changes, use it at your own risk.

make clean

Also reset the student id: this is required before pushing any modification to any of the exercises.

make realclean

Help

Ask any questions or file an issue at the original GitHub repo.

License

Copyright 2021-2023 by its authors. Some rights reserved. See AUTHORS.

Creative Commons Attribution-NonCommercial-ShareAlike - see LICENSE for full text.

Acknowledgments

Examples adopted from the Go: Bootcamp Course.