Starter Code
Learn about how to create starter code for a language
Starter code is the code that we provide to users when they start a challenge. It’s the code that they’ll be building on top of.
1. Run course-sdk add-language <language>
Clone build-your-own-<challenge>
For instance, if you’re adding support for the Kafka challenge, clone the build-your-own-kafka repository.
Run course-sdk add-language <language>
a. Install course-sdk if it’s not already installed.
b. In the cloned challenge repository, run the following command:
Check available languages here.
2. Edit starter code
The starter code will be copied to starter_templates/<language>
.
Suppose you’re adding C support, open and edit starter_templates/c/code/src/main.c
:
Make necessary edits so the code can pass the first stage of the challenge.
3. Run course-sdk test <language>
We have comprehensive CI tests in place to ensure that the starter code and Dockerfile for each language are valid.
In the cloned challenge repository, run the following command:
Ensure all tests pass before submitting a pull request (PR).
First stage solution
To make it easier for users to get started, we automatically generate a solution to the first stage of the challenge. This is done by uncommenting lines in the starter code.
Example:
Stage 1 solution, auto-generated from starter code
The way this works is that course-sdk will look for markers like this in the starter code:
These markers will be deleted and any code after them will be uncommented to generate the solution.
The full logic for this is here.
Was this page helpful?