Skip to content
/ go-dojo Public

A collection of challenges for the go programming language

License

Notifications You must be signed in to change notification settings

fasmat/go-dojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZCamp 2021 Coding Dojo - Concurrency in Go

GitHub Actions CI

Introduction

go Logo

This coding dojo was created to have some fun during the #ZCamp2021 and learn Go together.

How to participate

  1. Download and install VSCode
  2. Download and install Docker
  3. 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!

Challenges

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

Contributing

Feel free to submit a PR. I'm happy to extend and improve these challenges.

About

A collection of challenges for the go programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages