Thank you for your interest in contributing to the D1 Go SQL Driver! We welcome contributions from the community.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/d1_go_sql.git cd d1_go_sql - Install dependencies:
make deps
- Ensure you have Go 1.21 or later installed
- Set up your Cloudflare credentials for testing:
export CLOUDFLARE_ACCOUNT_ID="your-account-id" export CLOUDFLARE_API_TOKEN="your-api-token" export D1_DATABASE_ID="your-database-id"
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name
-
Make your changes following our coding standards
-
Format your code:
make fmt
-
Run tests:
make test -
Run linters:
make lint
-
Commit your changes with clear, descriptive commit messages:
git commit -m "Add feature: description of your changes"
- 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
Examples:
Add support for named parameters
Fix connection leak in transaction rollback
Update documentation for DSN format
- Follow standard Go conventions and idioms
- Use
gofmtfor formatting (runmake fmt) - Keep functions focused and single-purpose
- Write clear, self-documenting code with meaningful variable names
- Document all exported types, functions, and constants
- Include examples in documentation where appropriate
- Keep README.md up to date with new features
- Add inline comments for complex logic
- Write unit tests for all new functionality
- Maintain or improve code coverage
- Test edge cases and error conditions
- Use table-driven tests where appropriate
Example test structure:
func TestFeature(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
// test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// test implementation
})
}
}- Return errors rather than panicking
- Wrap errors with context using
fmt.Errorfwith%w - Define custom error types for specific error conditions
- Use clear, actionable error messages
- Avoid unnecessary allocations
- Use efficient algorithms and data structures
- Profile code for performance-critical sections
- Document any performance trade-offs
- Update documentation for any changed functionality
- Add tests for new features or bug fixes
- Ensure all tests pass:
make test - Ensure code is formatted:
make fmt - Ensure no linter errors:
make lint - Update CHANGELOG.md if applicable
- Submit your pull request with a clear description
## Description
Brief description of the changes
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
Describe the tests you ran and how to reproduce them
## Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes- At least one maintainer will review your pull request
- Address any feedback or requested changes
- Once approved, a maintainer will merge your pull request
When reporting bugs, please include:
- Description: Clear description of the bug
- Steps to reproduce: Detailed steps to reproduce the issue
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Environment: Go version, OS, and relevant configuration
- Code samples: Minimal code to reproduce the issue
- Error messages: Full error messages and stack traces
When requesting features, please include:
- Use case: Describe the problem you're trying to solve
- Proposed solution: Your suggested approach
- Alternatives: Other approaches you've considered
- Additional context: Any other relevant information
- GitHub Issues: For bug reports and feature requests
- GitHub Discussions: For questions and general discussion
By contributing, you agree that your contributions will be licensed under the MIT License.
Contributors will be recognized in the project's README.md and CHANGELOG.md.
Thank you for contributing to D1 Go SQL Driver! 🎉