Contributing to Go Overlay¶
Thank you for your interest in contributing to Go Overlay! This guide will help you get started with contributing to the project.
Getting Started¶
Before you begin:
- Make sure you have Go installed (version 1.21 or later)
- Familiarize yourself with the project by reading the documentation
- Check the roadmap to see what features are planned
- Look at existing issues and pull requests to avoid duplicate work
Fork and Pull Request Workflow¶
1. Fork the Repository¶
- Navigate to the Go Overlay repository
- Click the "Fork" button in the top right corner
- Clone your fork locally:
2. Create a Branch¶
Create a new branch for your feature or bug fix:
Use descriptive branch names: - feature/ for new features - fix/ for bug fixes - docs/ for documentation changes - refactor/ for code refactoring
3. Make Your Changes¶
Make your changes following the code style guidelines below. Ensure your code:
- Follows Go best practices
- Includes appropriate comments
- Handles errors properly
- Is well-tested
4. Commit Your Changes¶
Write clear, descriptive commit messages:
Good commit message examples: - Add support for environment variable substitution in config - Fix race condition in service state management - Refactor timeout handling for better clarity - Update documentation for dependency management
5. Push and Create Pull Request¶
Push your changes to your fork:
Then:
- Go to your fork on GitHub
- Click "Compare & pull request"
- Fill in the PR template with:
- Description of changes
- Related issue numbers (if applicable)
- Testing performed
- Screenshots (if UI changes)
- Submit the pull request
6. Code Review Process¶
- Maintainers will review your PR
- Address any feedback or requested changes
- Once approved, your PR will be merged
Code Style Guidelines¶
Go Code Style¶
Follow standard Go conventions:
- Use
gofmtto format your code - Follow Effective Go guidelines
- Use meaningful variable and function names
- Keep functions focused and concise
// Good: Clear, descriptive names
func StartServiceWithTimeout(service *Service, timeout time.Duration) error {
// Implementation
}
// Bad: Unclear abbreviations
func StSvcWT(s *Service, t time.Duration) error {
// Implementation
}
Error Handling¶
Always handle errors explicitly:
// Good
result, err := someOperation()
if err != nil {
return fmt.Errorf("failed to perform operation: %w", err)
}
// Bad
result, _ := someOperation()
Comments¶
- Add comments for exported functions and types
- Use godoc-style comments
- Explain complex logic
// StartService initializes and starts the specified service.
// It returns an error if the service fails to start within the configured timeout.
func StartService(service *Service) error {
// Implementation
}
Package Organization¶
- Keep related functionality together
- Use internal packages for implementation details
- Export only what's necessary
Testing Requirements¶
All contributions must include appropriate tests.
Writing Tests¶
- Place tests in
*_test.gofiles - Use table-driven tests for multiple scenarios
- Test both success and error cases
- Aim for good code coverage
Example test structure:
func TestServiceStart(t *testing.T) {
tests := []struct {
name string
service *Service
wantErr bool
}{
{
name: "successful start",
service: &Service{Name: "test", Command: "echo"},
wantErr: false,
},
{
name: "invalid command",
service: &Service{Name: "test", Command: ""},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.service.Start()
if (err != nil) != tt.wantErr {
t.Errorf("Start() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
Running Tests¶
Run all tests before submitting:
# Run all tests
make test
# Run tests with coverage
go test -cover ./...
# Run tests with verbose output
go test -v ./...
Test Coverage¶
- Aim for at least 70% code coverage
- Focus on testing critical paths
- Include edge cases and error conditions
Documentation¶
If your changes affect user-facing functionality:
- Update relevant documentation in the
docs/directory - Add examples if introducing new features
- Update the README if necessary
- Keep documentation clear and concise
Reporting Issues¶
When reporting bugs or requesting features:
- Check if the issue already exists
- Use the issue template
- Provide clear reproduction steps
- Include relevant logs and configuration
- Specify your environment (OS, Go version, etc.)
Code of Conduct¶
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Help maintain a positive community
Questions?¶
If you have questions:
- Open a discussion on GitHub
- Check existing documentation
- Review closed issues for similar questions
Thank you for contributing to Go Overlay! 🎉