This coding dojo was created to have some fun during the #ZCamp2021 and learn Go together.
- Download and install VSCode
- Download and install Docker
- Install the extension Remote Containers
When you clone the repository and open the directory inside VSCode it should prompt you to re-open it in a docker container. If it doesn't click the green Icon in the bottom left of the VSCode window and select "Reopen in Container". The container that is started by VSCode already is configured for the challenge. You can test if it works by:
go build -v ./...
Which should pass without any errors.
The first start of the Container takes ~1 minute with fast internet connection, after that you are ready to go!
Note: This example was taken and extended from https://tour.golang.org/concurrency/10
The Crawl
function uses a Fetcher
to fetch a website from a given URL and recursively continue to crawl URLs until a certain depth.
The goal of this challenge is to extend this program to a more full-featured tool that works more efficiently can deal with uncooperative servers. Only modify the contents of challenge01.go! You have completed a task when the corresponding test passes. To start the tests use
go test -v -race ./challenge01
This ensures that the race detector is active during the tests. Take a look at challenge01_test.go to start working on the tasks.
# | Summary |
---|---|
1 | Fetch each URL only once to save bandwidth |
2 | Fetch URLs concurrently to speed up the crawler |
3 | Add the option to limit the rate at which the crawler fetches the server |
Disclaimer: The idea for this challenge came from Just for Func and more specifically this video.
The goal of this challenge is to re-implement the official context package. It is widely used in applications to carry deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes. For further information see the official documentation.
In this challenge the foundation for the package is already layed. There is a single test already available, but it is unfortunately failing. Fix this test and then proceed to implement the whole package in a TDD fashion test after test.
The whole context package without tests is < 350 lines of code and can be used as a reference if you get stuck. Remember to run all tests with the race detector enabled to ensure the context package is concurrency safe.
go test -v -race ./challenge02
Feel free to submit a PR. I'm happy to extend and improve these challenges.