Welcome to the Go Interview Practice repository!
This repository contains a series of Go (Golang) coding challenges designed to help you prepare for technical interviews. Each challenge includes detailed instructions, automated tests, and per-challenge scoreboards to track your progress. Bash scripts are provided to streamline solution submission and testing.
- Getting Started
- Working on Challenges
- Submitting Your Solution
- Scripts and Automation
- Contributing
- License
- Go (Golang) Installed: Ensure you have Go installed on your machine. You can download it from the official website.
- Git Installed: You'll need Git to clone repositories and manage code versions. Download it from here.
Forking the repository creates a copy under your own GitHub account where you can make changes without affecting the original repository.
- Go to the original repository.
- Click the Fork button in the top right corner.
Clone your forked repository to your local machine:
git clone https://github.com/yourusername/go-interview-practice.git
We have provided a bash script called create_submission.sh
to help you set up your submission directory and copy the solution template.
Usage:
./create_submission.sh [challenge-number]
Example:
./create_submission.sh 1
Steps:
-
Navigate to the root directory of the cloned repository.
-
Run the script with the challenge number you want to work on.
./create_submission.sh 1
-
The script will prompt you to enter your GitHub username. This is used to create a unique submission directory for you.
-
The script will create the directory
challenge-1/submissions/yourusername
and copy the solution template into it.
-
Navigate to your submission directory:
cd challenge-1/submissions/yourusername/
-
Open the
solution-template.go
file in your preferred text editor. -
Implement the required function(s) as specified in the challenge's
README.md
.
Each challenge includes a run_tests.sh
script to help you run tests against your solution.
Usage:
-
Navigate to the challenge directory:
cd challenge-1
-
Run the test script:
./run_tests.sh
-
Enter your GitHub username when prompted.
-
The script will run the tests and display the results.
-
Commit Your Changes:
git add challenge-1/submissions/yourusername/solution-template.go git commit -m "Add Challenge 1 solution"
-
Push to Your Fork:
git push origin challenge-1-solution
-
Create a Pull Request:
- Go to your forked repository on GitHub.
- Click on the "Compare & pull request" button.
- Submit the pull request to the original repository's
main
branch.
-
Wait for Automated Feedback:
- The GitHub Actions workflow will automatically run tests on your submission.
- Review the test results in the Checks tab of your pull request.
- If tests pass, your submission will be reviewed and merged.
- If tests fail, fix the issues and push the changes. The workflow will re-run the tests.
We've included two bash scripts to streamline your workflow:
This script sets up your submission directory and copies the solution template.
Location: Root directory of the repository.
Usage:
./create_submission.sh [challenge-number]
What It Does:
- Prompts you for your GitHub username.
- Creates a submission directory under
challenge-[number]/submissions/yourusername
. - Copies the
solution-template.go
into your submission directory. - Initializes the Go module if necessary.
This script runs the tests against your solution.
Location: Inside each challenge directory (e.g., challenge-1/run_tests.sh
).
Usage:
./run_tests.sh
What It Does:
- Prompts you for your GitHub username.
- Copies your solution file into the challenge directory.
- Runs the tests.
- Cleans up any temporary files used during testing.
We welcome contributions! Please read the CONTRIBUTING.md file for details on our code of conduct, and the process for submitting pull requests.
If you'd like to add a new challenge to the repository, please follow these steps:
-
Create a New Branch:
git checkout -b add-challenge-[number]
-
Create the Challenge Directory Structure:
challenge-[number]/ ├── README.md ├── solution-template.go ├── solution-template_test.go └── submissions/
-
Write the Challenge Description:
- In
challenge-[number]/README.md
, provide:- Problem statement
- Function signature
- Input/output formats
- Sample inputs/outputs
- Detailed instructions
- In
-
Create the Solution Template:
- In
challenge-[number]/solution-template.go
, provide the skeleton code with function signatures and comments.
- In
-
Write the Test File:
- In
challenge-[number]/solution-template_test.go
, write comprehensive tests covering various cases.
- In
-
Update the Main README:
- Add the new challenge to the list of available challenges in the main
README.md
.
- Add the new challenge to the list of available challenges in the main
-
Commit and Push:
git add challenge-[number] git commit -m "Add Challenge [number]: [Challenge Title]" git push origin add-challenge-[number]
-
Create a Pull Request:
- Submit a pull request to the original repository.
- Ensure that all tests pass in the continuous integration workflow.
This project is licensed under the MIT License - see the LICENSE file for details.