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.
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
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.
At any point in time you can test your solutions as follows.
make test
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).
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
If you have uncommitted changes, follow the below steps.
-
Store your changes temporarily.
git stash
-
Pull updates.
git pull
-
Restore your changes.
git stash
-
Optional: fix conflicts and re-run tests.
Add a new subdirectory and add the following files:
exercise.yaml
: An exercise definition with a set of inputs, from whichmake 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.
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.
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.
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
Ask any questions or file an issue at the original GitHub repo.
Copyright 2021-2023 by its authors. Some rights reserved. See AUTHORS.
Creative Commons Attribution-NonCommercial-ShareAlike - see LICENSE for full text.
Examples adopted from the Go: Bootcamp Course.