First off, thank you for considering contributing to go-fluent-sql! 🎉
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Pull Request Process
- Coding Guidelines
- Testing Guidelines
- Commit Messages
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/go-fluent-sql.git - Add upstream remote:
git remote add upstream https://github.com/biyonik/go-fluent-sql.git - Create a branch:
git checkout -b feature/your-feature-name
- Go 1.21 or higher
- Make (optional, but recommended)
- Docker (optional, for integration tests)
# Clone the repository
git clone https://github.com/biyonik/go-fluent-sql.git
cd go-fluent-sql
# Install dependencies
go mod download
# Install development tools
make install-tools
# Run tests to verify setup
make testmake help # Show all available commands
make test # Run tests
make test-coverage # Run tests with coverage
make lint # Run linter
make fmt # Format code
make pre-commit # Run all pre-commit checksBefore creating a bug report, please check existing issues. When creating a bug report, include:
- Clear title describing the issue
- Steps to reproduce the behavior
- Expected behavior vs actual behavior
- Code samples if applicable
- Go version and OS information
Feature requests are welcome! Please:
- Check if the feature has already been requested
- Provide a clear description of the feature
- Explain the use case and benefits
- Consider if it fits the project's scope
- Small changes: Bug fixes, typos, documentation improvements
- Medium changes: New features, refactoring
- Large changes: Architectural changes, new modules
For medium/large changes, please open an issue first to discuss.
- Update documentation if you're changing functionality
- Add tests for new features
- Ensure all tests pass:
make test - Run linter:
make lint - Update CHANGELOG.md if applicable
- Fill out the PR template completely
- Tests pass locally
- Linter passes
- Documentation updated
- Commit messages follow convention
- PR description explains changes
We follow the standard Go style guidelines:
// ✅ DO: Use context as first parameter
func (qb *QueryBuilder) GetContext(ctx context.Context, dest any) error
// ❌ DON'T: Panic in library code
panic("something went wrong")
// ✅ DO: Return errors
return fmt.Errorf("query failed: %w", err)
// ✅ DO: Use meaningful variable names
userCount := len(users)
// ❌ DON'T: Use single letter names (except loops)
u := len(users)
// ✅ DO: Document exported functions
// GetContext executes the query and scans results into dest.
// It accepts a context for timeout and cancellation support.
func (qb *QueryBuilder) GetContext(ctx context.Context, dest any) error// Use sentinel errors for expected conditions
var ErrNoRows = errors.New("fluentsql: no rows in result set")
// Wrap errors with context
if err != nil {
return fmt.Errorf("failed to compile query: %w", err)
}func TestQueryBuilder_Where(t *testing.T) {
// Arrange
grammar := NewMySQLGrammar()
qb := NewBuilder(nil, grammar)
// Act
qb.Table("users").Where("status", "=", "active")
sql, args, err := qb.ToSQL()
// Assert
require.NoError(t, err)
assert.Equal(t, "SELECT * FROM `users` WHERE `status` = ?", sql)
assert.Equal(t, []interface{}{"active"}, args)
}TestFunctionName_Scenario_ExpectedBehavior- Example:
TestQueryBuilder_Where_WithMaliciousInput_ReturnError
- Minimum 70% coverage for new code
- Critical paths (security, data handling) should have higher coverage
We follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasksci: CI/CD changes
feat(builder): add WhereIn method with SQL injection protection
fix(grammar): resolve map iteration order non-determinism
docs(readme): add installation instructions
test(security): add SQL injection test cases
Feel free to open an issue with the question label or reach out to the maintainers.
Thank you for contributing! 🙏