First off, thank you for considering contributing to go-collections! It's people like you who make go-collections such a great tool.
By participating in this project, you are expected to uphold our Code of Conduct:
- Use welcoming and inclusive language
- Be respectful of differing viewpoints and experiences
- Gracefully accept constructive criticism
- Focus on what is best for the community
- Show empathy towards other community members
Before creating bug reports, please check the issue list as you might find out that you don't need to create one. When you are creating a bug report, please include as many details as possible:
- Use a clear and descriptive title
- Describe the exact steps to reproduce the problem
- Provide specific examples to demonstrate the steps
- Describe the behavior you observed after following the steps
- Explain which behavior you expected to see instead and why
- Include your Go version (
go version
) - Include any relevant code snippets or test cases
// Example of a good bug report code snippet
ds := disjointset.New[int]()
ds.MakeSet(1)
ds.MakeSet(2)
ds.Union(1, 2)
// Expected: ds.Connected(1, 2) == true
// Actual: ds.Connected(1, 2) == false
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include:
- Use a clear and descriptive title
- Provide a step-by-step description of the suggested enhancement
- Provide specific examples to demonstrate the steps
- Describe the current behavior and explain which behavior you expected to see instead
- Explain why this enhancement would be useful
- List some other libraries or applications where this enhancement exists
- Fork the repo and create your branch from
main
- If you've added code that should be tested, add tests
- If you've changed APIs, update the documentation
- Ensure the test suite passes
- Make sure your code follows the existing style
- Issue that pull request!
- Install Go 1.18 or higher (for generics support)
- Fork and clone the repository:
git clone https://github.com/yourusername/go-collections.git cd go-collections
- Install dependencies:
go mod download
- Run tests:
go test ./...
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
- Follow the official Go Code Review Comments
- Write idiomatic Go code:
// Good var items []string for _, item := range collection { items = append(items, item) } // Bad items := make([]string, 0) for i := 0; i < len(collection); i++ { items = append(items, collection[i]) }
- Use meaningful variable names
- Add comments for exported functions and types
- Maintain existing code style
- Use
go fmt
before committing - Handle errors appropriately
- Write table-driven tests
- Use Markdown for documentation
- Reference functions and types with backticks:
Queue.Enqueue()
- Include code examples for new features
- Document performance characteristics
- Update README.md with any necessary changes
- Add doc comments for all exported functions and types:
// Push adds an item to the top of the stack. // Returns false if the stack is full. func (s *Stack[T]) Push(item T) bool { // Implementation }
- Write test cases for all new functionality
- Use table-driven tests where appropriate:
func TestStack(t *testing.T) { tests := []struct { name string input []int expected int }{ {"single item", []int{1}, 1}, {"multiple items", []int{1, 2, 3}, 3}, // More test cases... } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Test implementation }) } }
- Aim for high test coverage
- Include both positive and negative test cases
- Test edge cases and error conditions
Feel free to open an issue if you have any questions about contributing!
By contributing, you agree that your contributions will be licensed under the MIT License.