We welcome contributions to pgdbtemplate! This document provides guidelines
for contributing to the project.
- Fork the repository on GitHub
- Clone your fork locally
- Create a new branch for your feature or bugfix
- Make your changes
- Add or update tests as necessary
- Ensure all tests pass
- Submit a pull request
- Go 1.20 or later
- PostgreSQL 9.5 or later (for testing)
- Git
# Clone your fork
git clone https://github.com/yourusername/pgdbtemplate.git
cd pgdbtemplate
# Install dependencies
go mod tidy
# Run tests
go test -v ./...
# Run tests with race detection
go test -race -v ./...
# Check code formatting
go fmt ./...
# Run linter
go vet ./...- Follow standard Go conventions
- Use
gofmtfor formatting - Add comments for all exported functions and types
- End all comment sentences with full stops
- Use meaningful variable and function names
- Keep functions focused and small
// Good: DatabaseConnection represents any PostgreSQL database connection.
type DatabaseConnection interface { ... }
// Bad: DatabaseConnection represents any PostgreSQL database connection
type DatabaseConnection interface { ... }- All new features must include tests
- Tests should use real PostgreSQL connections when possible
- Use the
pgdbtemplate_testpackage for external API testing - Use
frankban/quicktestfor test assertions - Maintain or improve test coverage
# Run all tests
go test -v ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.outAll pull requests are automatically tested using GitHub Actions with:
- Go 1.20
- Race detection
- Coverage reporting
-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes with clear, atomic commits:
git commit -m "Add feature: description of what you added" -
Update documentation if necessary
-
Add tests for new functionality
-
Ensure all tests pass:
go test -v ./... go test -race -v ./...
-
Push to your fork and create a pull request
Use clear, descriptive commit messages:
Good:
- Add support for custom admin database names
- Fix race condition in template initialization
- Update documentation for testcontainers integration
Bad:
- Fix bug
- Update code
- Changes
- Title: Clear, descriptive title explaining what the PR does
- Description: Explain the motivation and changes made
- Tests: Include tests for new features or bug fixes
- Documentation: Update README.md if the API changes
- Breaking changes: Clearly mark any breaking changes
Include the following information:
- Go version
- PostgreSQL version
- Operating system
- Code example that reproduces the issue
- Expected vs actual behavior
- Error messages and stack traces
- Describe the use case and motivation
- Provide examples of how the feature would be used
- Consider backward compatibility
- Discuss implementation approaches if you have ideas
- GitHub Issues: For bugs, feature requests, and questions
- Discussions: For general questions and community interaction
- Code review: For feedback on implementation approaches
By contributing to pgdbtemplate, you agree that your contributions
will be licensed under the MIT License.
- Be respectful and inclusive
- Help newcomers get started
- Provide constructive feedback
- Focus on the code and ideas, not the person
- Assume good intentions
Thank you for contributing to pgdbtemplate! 🚀