Thank you for your interest in contributing to the Go Interview Practice repository! We welcome contributions from the community to help improve this project. Whether you want to submit solutions, add new challenges, or improve documentation, your efforts are appreciated.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.
You can submit solutions to both Classic and Package challenges:
-
Fork the Repository:
- Click the "Fork" button on the repository page.
-
Clone Your Fork:
git clone https://github.com/yourusername/go-interview-practice.git
-
Create a New Branch:
git checkout -b challenge-[number]-solution
-
Set Up Your Submission:
-
Use the provided script to set up your submission:
./create_submission.sh [challenge-number]
-
-
Implement Your Solution:
- Edit the
solution-template.gofile in your submission directory. - Ensure your code passes all the tests.
- Edit the
-
Run Tests Locally:
-
Navigate to the challenge directory and use
run_tests.sh:cd challenge-[number] ./run_tests.sh
-
-
Commit and Push:
git add challenge-[number]/submissions/yourusername/ git commit -m "Add Challenge [number] solution by [yourusername]" git push origin challenge-[number]-solution
-
Fork and Clone (same as above)
-
Create a New Branch:
git checkout -b package-[package-name]-challenge-[number]-solution
-
Navigate to the Package Challenge:
cd packages/[package-name]/challenge-[number]-[topic] -
Create Your Submission Directory:
mkdir -p submissions/yourusername
-
Implement Your Solution:
-
Copy the
solution-template.goto your submission directory:cp solution-template.go submissions/yourusername/solution.go
-
Edit
submissions/yourusername/solution.goand complete all TODOs. -
Ensure your solution follows the package requirements and passes all tests.
-
-
Run Tests Locally:
-
Use the package challenge test script:
./run_tests.sh # When prompted, enter your GitHub username
-
-
Commit and Push:
git add packages/[package-name]/challenge-[number]-[topic]/submissions/yourusername/ git commit -m "Add [Package] Challenge [number] solution by [yourusername]" git push origin package-[package-name]-challenge-[number]-solution
-
Create a Pull Request:
- Go to your fork on GitHub and open a pull request to the
mainbranch. - Use a descriptive title and mention which challenge you solved.
- Go to your fork on GitHub and open a pull request to the
-
Receive Feedback:
- The automated tests will run on your pull request.
- Address any comments or requested changes.
- Package challenge solutions will be automatically added to the scoreboard upon merge.
There are two types of challenges you can contribute:
Before contributing a new challenge, it's important to understand the difference between the two types:
Classic Challenges:
- Focus: Algorithm and data structure problems
- Purpose: Fundamental programming concepts and problem-solving skills
- Structure: Single challenge directory with standalone problems
- Examples: Binary search, linked list manipulation, dynamic programming
- Target Audience: All developers regardless of framework experience
- Location:
challenge-[number]/directories in the root
Package Challenges:
- Focus: Real-world application development with specific Go packages/frameworks
- Purpose: Practical skills for building production applications
- Structure: Package-based directory with progressive challenge series
- Examples: REST APIs with Gin, CLI tools with Cobra, database operations with GORM
- Target Audience: Developers learning specific frameworks or building portfolio projects
- Location:
packages/[package-name]/challenge-[number]-[topic]/directories
When to Choose Each Type:
-
Choose Classic Challenges for:
- Algorithm problems from coding interviews
- Data structure implementations
- Mathematical or logical puzzles
- Language-agnostic programming concepts
-
Choose Package Challenges for:
- Framework-specific tutorials
- Building complete applications
- Learning industry-standard libraries
- Demonstrating real-world development patterns
For traditional algorithm and data structure challenges:
-
Create a New Issue:
- Open an issue to discuss the new challenge idea.
- Provide details such as the problem statement and its relevance.
-
Wait for Approval:
- Wait for maintainers or community members to provide feedback.
-
Create a New Branch:
git checkout -b add-challenge-[number]
-
Set Up the Challenge Directory:
challenge-[number]/ ├── README.md ├── solution-template.go ├── solution-template_test.go ├── learning.md ├── hints.md ├── run_tests.sh └── submissions/ -
Write the Challenge Description:
- Include problem statement, function signature, input/output format, constraints, and sample inputs/outputs in
README.md.
- Include problem statement, function signature, input/output format, constraints, and sample inputs/outputs in
-
Create Learning Materials:
- In
challenge-[number]/learning.md, provide:- Explanations of relevant Go concepts needed for the challenge
- Code examples demonstrating these concepts
- Best practices and efficiency considerations
- Links to further reading resources
- In
-
Create the Solution Template:
- Provide a skeleton code in
solution-template.gowith appropriate comments.
- Provide a skeleton code in
-
Write Comprehensive Tests:
- Create
solution-template_test.gowith detailed test cases covering various scenarios, including edge cases.
- Create
-
Create Hints:
- Provide step-by-step guidance in
hints.mdwithout giving away the complete solution.
- Provide step-by-step guidance in
-
Create Test Script:
- Create an executable
run_tests.shscript for testing submissions.
- Create an executable
-
Update Documentation:
- Add the new challenge to the main
README.md.
- Add the new challenge to the main
For challenges that focus on specific Go packages/frameworks:
-
Create a New Issue:
- Open an issue to discuss the new package challenge idea.
- Specify the package/framework (e.g., Gin, Cobra, GORM) and challenge focus.
-
Wait for Approval:
- Wait for maintainers or community members to provide feedback.
-
Create a New Branch:
git checkout -b add-package-[package-name]-challenge-[number]
-
Set Up the Package Challenge Directory:
packages/[package-name]/ ├── package.json # Package metadata and learning path └── challenge-[number]-[topic]/ ├── metadata.json # Challenge-specific metadata ├── README.md # Challenge description ├── solution-template.go # Template with TODOs ├── solution-template_test.go # Comprehensive tests ├── go.mod # Module with dependencies ├── go.sum # Dependency checksums ├── learning.md # In-depth educational content ├── hints.md # Step-by-step guidance ├── run_tests.sh # Testing script ├── SCOREBOARD.md # Auto-generated scoreboard └── submissions/ # User solutions └── [username]/ └── solution.go # Complete working solution -
Create Package Metadata (if new package):
- Create
packages/[package-name]/package.jsonwith:- Package information (name, description, GitHub repo)
- Learning path defining challenge progression
- Categories and difficulty levels
- Create
-
Create Challenge Metadata:
- Create
metadata.jsonwith:- Title, description, difficulty, estimated time
- Learning objectives and prerequisites
- Requirements and bonus points
- Tags and real-world connections
- Create
-
Write the Challenge Description:
- Include practical problem statement, CLI/API requirements, and testing instructions in
README.md.
- Include practical problem statement, CLI/API requirements, and testing instructions in
-
Create Learning Materials:
- In
learning.md, provide comprehensive educational content (400+ lines):- Framework fundamentals and core concepts
- Code examples and patterns
- Best practices and real-world usage
- Advanced features and testing strategies
- In
-
Create the Solution Template:
- Provide a structured template in
solution-template.gowith:- Proper imports and dependencies
- Type definitions and structures
- Function signatures with TODO comments
- Helper functions and validation logic
- Provide a structured template in
-
Write Comprehensive Tests:
- Create
solution-template_test.gowith:- Unit tests for all functions and features
- Integration tests for complete workflows
- Edge cases and error scenarios
- Performance and behavior validation
- Create
-
Create Dependencies:
- Set up
go.modwith proper module name and Go version - Include all necessary dependencies for the package
- Run
go mod tidyto generatego.sum
- Set up
-
Create Hints:
- Provide detailed guidance in
hints.mdwith:- Step-by-step implementation guidance
- Code examples and patterns
- Common pitfalls to avoid
- Testing and debugging tips
- Provide detailed guidance in
-
Create Test Script:
- Create an executable
run_tests.shscript that:- Tests compilation and functionality
- Runs unit tests and functional tests
- Validates flag handling and argument processing
- Provides detailed feedback and next steps
- Create an executable
-
Create Working Solution:
- Implement a complete working solution in
submissions/RezaSi/solution.go - Ensure it passes all tests and demonstrates best practices
- Implement a complete working solution in
-
Update Documentation:
- Update package scoreboard using the package scoreboard scripts
- Ensure the web UI can discover and display the new challenge
-
Commit and Push:
# For classic challenges git add challenge-[number]/ git commit -m "Add Challenge [number]: [Challenge Title]" # For package challenges git add packages/[package-name]/ git commit -m "Add [Package] Challenge [number]: [Challenge Title]" git push origin [branch-name]
-
Create a Pull Request:
- Submit the pull request for review.
- Ensure all tests pass in the CI workflow.
- Include a detailed description of the challenge and its educational value.
-
Code Formatting:
- Use
gofmtto format your Go code. - Maintain consistent indentation and spacing.
- Use
-
Naming Conventions:
- Use descriptive variable and function names.
- Follow Go naming conventions (e.g.,
camelCasefor variables and functions).
-
Comments:
- Include comments to explain complex logic.
- Use doc comments (
//) for exported functions and types.
-
Test Writing:
- Write thorough tests covering various input cases.
- Use subtests (
t.Run()) to organize test cases.
-
Ensure All Tests Pass:
- Run tests locally before submitting your pull request.
- Check that your code does not break existing functionality.
-
Provide a Clear Description:
- Explain what changes you have made and why.
- Reference any related issues.
-
One Pull Request per Feature:
- Keep your pull requests focused on a single feature or fix.
-
Wait for Review:
- A maintainer will review your pull request.
- Be responsive to feedback and make necessary changes.
If you encounter any problems or have suggestions:
-
Open an Issue:
- Go to the Issues tab.
- Provide a detailed description of the issue or suggestion.
- Include steps to reproduce the issue if applicable.
For any questions or additional support:
- Email: [email protected]
- GitHub: RezaSi
Thank you for contributing to the Go Interview Practice repository!