Thank you for your interest in contributing to the Deidentify project! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Code Standards
- Testing
- Submitting Changes
- Release Process
This project adheres to a code of conduct that we expect all contributors to follow. Please be respectful and constructive in all interactions.
- Go: Version 1.19 or later
- Git: For version control
- gofmt: Included with Go installation
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/yourusername/deidentify.git cd deidentify - Add the original repository as upstream:
git remote add upstream https://github.com/aliengiraffe/deidentify.git
go mod downloadWe use a pre-commit hook to ensure all Go code is properly formatted. Run the setup script:
./scripts/setup-pre-commit-hook.shThis will:
- Install a git pre-commit hook that runs
gofmton staged Go files - Automatically format code before commits
- Prevent commits with formatting issues
Alternative manual setup: If you prefer to set it up manually, copy the pre-commit hook:
cp scripts/setup-pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commitTest that everything is working:
# Run tests
go test ./...
# Run examples
go run examples/basic/main.go
go run examples/table/main.go
go run examples/slices/main.gogit checkout -b feature/your-feature-name- Write your code following our Code Standards
- Add tests for new functionality
- Update documentation as needed
Run the comprehensive quality check script (recommended):
# Run all Go Report Card A+ quality checks
./scripts/dev-check.shThis single script runs all the checks below automatically and ensures your code meets the highest Go quality standards.
Or run individual checks manually:
go test ./... # Run tests
go test -v ./... # Verbose test output
go test -race ./... # Test with race detector
go test -bench=. ./... # Run benchmarks
go vet ./... # Static analysis
gofmt -l . # Check formatting
staticcheck ./... # Advanced static analysis
golangci-lint run # Comprehensive linting
gocyclo -over 15 . # Check cyclomatic complexityThe pre-commit hook will automatically format your code:
git add .
git commit -m "Add new feature: description"If the hook formats files, review the changes and commit again:
git commit -m "Add new feature: description"- Formatting: All code must be formatted with
gofmt(enforced by pre-commit hook) - Naming: Follow Go naming conventions
- Use
CamelCasefor exported functions/types - Use
camelCasefor internal functions/variables - Use descriptive names
- Package naming: Don't include package name in function names (e.g., use
Text()notDeidentifyText())
- Use
- Documentation:
- All exported functions must have documentation comments
- Start comments with the function name
- Provide usage examples for complex functions
-
Error Handling: Use Go's standard error patterns
- Return errors rather than panicking
- Provide descriptive error messages
- Wrap errors with context when appropriate
-
Testing:
- Write table-driven tests where appropriate
- Use descriptive test names
- Test both success and error cases
- Add benchmarks for performance-critical code
// Example demonstrates proper function documentation
// and error handling patterns used in this project.
func (d *Deidentifier) Example(input string) (string, error) {
if input == "" {
return "", nil
}
result, err := d.processInput(input)
if err != nil {
return "", fmt.Errorf("failed to process input: %w", err)
}
return result, nil
}# Run all tests
go test ./...
# Run specific test
go test -run TestDeidentifySlices
# Run tests with coverage
go test -cover ./...
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out- Unit Tests: Test individual functions in isolation
- Integration Tests: Test complete workflows
- Benchmarks: Include benchmarks for performance-critical functions
- Examples: Add
Examplefunctions for documentation
When adding new functionality:
- Write tests first (TDD approach recommended)
- Test edge cases: empty inputs, nil values, invalid data
- Test error conditions: ensure errors are properly returned
- Add benchmarks: for any performance-sensitive code
Before submitting, ensure your branch is up to date:
git fetch upstream
git rebase upstream/main-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub with:
- Clear title: Summarize the change in 50 characters or less
- Description: Explain what changes were made and why
- Testing: Describe how the changes were tested
- Breaking changes: Note any breaking changes
## Summary
Brief description of changes
## Changes Made
- List specific changes
- Include any new functions/types added
- Note any removed or modified functionality
## Testing
- [ ] All existing tests pass
- [ ] New tests added for new functionality
- [ ] Examples updated (if applicable)
- [ ] Benchmarks added (if applicable)
## Breaking Changes
List any breaking changes and migration steps
## Related Issues
Closes #123- All PRs require review before merging
- Address feedback promptly and update your branch
- Keep PRs focused - one feature/fix per PR
- Squash commits if requested during review
Releases are automated via GitHub Actions when tags are pushed:
# Create and push a tag
git tag v1.x.x
git push origin v1.x.xThe automation will:
- Run all tests
- Create a GitHub release
- Generate changelog
- Publish to Go module proxy
The scripts/ directory contains helpful development tools:
setup-pre-commit-hook.sh: Sets up the gofmt pre-commit hookdev-check.sh: Comprehensive Go Report Card A+ quality assurance script
Before submitting any PR, run the comprehensive quality check script:
./scripts/dev-check.shThis single script ensures your code meets Go Report Card A+ standards by running:
- Go code formatting (
gofmt -l) - All tests pass (
go test ./...) - Race condition detection (
go test -race ./...) - Clean build (
go build ./...) - Static analysis (
go vet ./...)
- Advanced static analysis (
staticcheck) - Comprehensive linting (
golangci-lint) - Cyclomatic complexity (
gocyclo- functions must be ≤15 complexity) - Example compilation (ensures documentation examples work)
- Code quality (checks for TODO/FIXME comments)
- Test coverage reporting (target: ≥80%)
The script automatically installs required quality tools if missing:
staticcheckgolangci-lintgocyclo
Upon successful completion, you'll see:
🎉 All Go Report Card A+ quality checks passed!
Your code meets the highest Go quality standards and is ready for submission.
Quality Summary:
✓ Formatting: gofmt compliant
✓ Testing: All tests pass with race detection
✓ Static Analysis: go vet, staticcheck, golangci-lint clean
✓ Complexity: All functions ≤15 cyclomatic complexity
✓ Examples: All compile successfully
✓ Code Quality: No TODO/FIXME comments
This ensures your contribution will earn an A+ rating on Go Report Card.
- Issues: Search existing issues or create a new one
- Discussions: Use GitHub Discussions for questions
- Documentation: Check examples and README.md
deidentify/
├── deidentify.go # Main implementation
├── deidentify_test.go # Main tests
├── patterns.go # Regex patterns for PII detection
├── data.go # Sample data for generation
├── examples/ # Usage examples
│ ├── basic/ # Simple text deidentification
│ ├── table/ # Structured data processing
│ ├── slices/ # Slice data processing
│ └── international/ # International address support
├── scripts/ # Development scripts
│ └── setup-pre-commit-hook.sh
├── CONTRIBUTING.md # This file
├── README.md # Project documentation
└── CLAUDE.md # AI context and guidelines
- Start small: Begin with documentation fixes or small features
- Ask questions: Create an issue to discuss large changes before implementing
- Test thoroughly: Run all tests and examples before submitting
- Follow conventions: Match the existing code style and patterns
- Be patient: Code review and feedback are part of the process
Thank you for contributing to Deidentify!