Thank you for your interest in contributing to go-safeinput! This document provides guidelines for contributing to this project.
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
The main goal is to keep the main branch always releasable with stable, backward-compatible code.
Before creating a bug report:
- Check if the issue has already been reported in the issue tracker
- Verify the issue against the latest version of the library
- Ensure the issue is actually related to this library and not user error
When creating a bug report, include:
- A clear and descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Go version and operating system
- Code samples demonstrating the issue
Feature suggestions are welcome! When suggesting a feature:
- Provide a detailed description of the feature
- Explain the use case and why it would be valuable
- Include example code showing how the feature would be used
- Consider if the feature aligns with the library's goal of zero external dependencies
-
Fork the repository
git clone https://github.com/YOUR_USERNAME/go-safeinput.git cd go-safeinput -
Create a feature branch
git checkout -b feature-name
-
Set up your development environment
# Ensure you have Go 1.23+ installed go version # Install development tools make tools
-
Make your changes
- Follow Go best practices and idioms
- Use camelCase for naming
- Add appropriate comments and documentation
- Implement proper error handling
- Maintain zero external dependencies (standard library only)
-
Write tests
- Add tests for all new functionality
- Ensure test coverage remains at 90% or higher
- Run tests with race detection
-
Run quality checks
# Format your code make fmt # Run linter make lint # Run tests make test # Run security checks make security
-
Commit your changes
- Use clear, descriptive commit messages
- Start with a capital letter
- Use past tense ("Added feature" not "Add feature")
- Reference related issues if applicable
git commit -m "Added validation for special characters in SQL identifiers" -
Push to your fork
git push origin feature-name
-
Open a Pull Request
- Provide a clear description of the changes
- Reference any related issues
- Ensure all CI checks pass
- Minimum coverage: 90% for all new code
- Race detection: All tests must pass with
-raceflag - Test naming: Use descriptive names that explain what is being tested
# Run tests with coverage
make test
# Generate HTML coverage report
make coverage-htmlAll code must pass golangci-lint with no errors:
make lint- Formatting: Code must be formatted with
gofmtandgoimports - Naming: Follow Go naming conventions (camelCase, no underscores)
- Comments: Export all public functions and types with documentation comments
- Error handling: Always check and handle errors appropriately
- Dependencies: Avoid external dependencies; use only the Go standard library
- Run security checks before submitting:
make security - Be mindful of potential vulnerabilities
- Never introduce code that could create security issues
# Run all quality checks (lint + test)
make all
# Run tests with coverage verification
make test
# Run linter
make lint
# Run security scanners
make security
# Format code
make fmt
# Tidy dependencies
make tidy
# Generate HTML coverage report
make coverage-html
# Install development tools
make tools
# Clean build artifacts
make cleanBefore submitting your pull request, ensure:
- Code is formatted (
make fmt) - Linter passes with no errors (
make lint) - All tests pass (
make test) - Test coverage is at 90% or higher
- Security checks pass (
make security) - New code has comprehensive tests
- Public functions/types have documentation comments
- Commit messages are clear and descriptive
- No external dependencies were added
- Changes are backward compatible
- Open an issue for questions about contributing
- Check existing issues and pull requests for similar discussions
- Refer to the README for project overview and usage
By contributing to go-safeinput, you agree that your contributions will be licensed under the MIT License.