Thank you for your interest in contributing to go-docx! This document provides guidelines and workflow information for contributors.
Note: This project was completely rewritten in 2024-2025 with a clean architecture design. All code follows modern Go practices and comprehensive testing standards.
- Read the docs: README.md, V2_DESIGN.md
- Check issues: Look for
good-first-issueorhelp-wantedlabels - Follow Git Flow: Branch from
dev, PR back todev - Write tests: Aim for 95%+ coverage
- Update docs: Keep README and examples in sync
We use a simplified Git Flow branching strategy to maintain code quality and stability:
master: Production-ready code only. This branch contains stable releases and is tagged with semantic versions (e.g.,v0.1.0-slidelang,v0.2.0-slidelang).dev: Integration branch where features are tested before release. All development work merges here first.- Feature branches: Short-lived branches for specific features, bug fixes, or improvements. Named with prefixes like
feature/,fix/,docs/, etc.
Follow these steps to contribute:
Fork the repository to your GitHub account, then clone your fork:
git clone https://github.com/YOUR_USERNAME/go-docx.git
cd go-docxAdd the original repository as upstream (if not already added):
git remote add upstream https://github.com/mmonterroca/docxgo.git
git remote -v # Verify remotesAlways branch from dev:
git checkout dev
git pull upstream dev # Get latest changes
git checkout -b feature/your-feature-nameBranch naming conventions:
feature/feature-name- New featuresfix/bug-description- Bug fixesdocs/what-changed- Documentation changestest/what-tested- Test additionsrefactor/what-refactored- Code refactoringperf/what-improved- Performance improvements
Write your code following the project's style:
- Run
go fmt ./...before committing - Add tests for new features
- Update documentation as needed
- Ensure existing tests pass:
go test ./...
Use descriptive commit messages following Conventional Commits:
git add .
git commit -m "feat: add support for STYLEREF field"Commit message format:
<type>: <short description>
[optional body with more details]
[optional footer with breaking changes or issue references]
Types:
feat:New featuresfix:Bug fixesdocs:Documentation changestest:Test additions or modificationsrefactor:Code refactoring without feature changesperf:Performance improvementschore:Maintenance tasks (dependencies, build, etc.)
Examples:
git commit -m "feat: add HYPERLINK field support"
git commit -m "fix: prevent empty RunProperties XML elements"
git commit -m "docs: update TOC examples in README"
git commit -m "test: add coverage for bookmark generation"git push origin feature/your-feature-name- Go to the original repository
- Click "New Pull Request"
- Important: Set base branch to
dev(NOTmaster) - Set compare branch to your feature branch
- Fill in the PR template:
- Clear description of changes
- Reference related issues
- List any breaking changes
- Add screenshots/examples if applicable
- Wait for maintainer review
- Address feedback by pushing additional commits
- Engage in discussion if needed
- Once approved, maintainers will merge to
dev
Periodically, maintainers will:
- Merge
dev→master - Tag the release with semantic version
- Create GitHub release with changelog
Current priorities for v2 development:
- ✅ Complete file I/O: Finish XML serialization and .docx writing
- ✅ Headers/Footers: Proper section support
- ✅ Styles: Complete styles management
- ✅ Fields: TOC, page numbers, cross-references
- ✅ Bug fixes: Any issues in current implementation
- ✅ Test coverage: Maintain 95%+ coverage
- ✅ Images & Drawings: Media file handling
- ✅ Builder Pattern: Fluent API (planned for v2.1)
- ✅ Performance: Optimization opportunities
- ✅ Documentation: Better examples, tutorials
- ✅ Migration Tools: Help users migrate from v1
- ✅ Advanced formatting: SmartArt, equations, charts
- ✅ Comments & Tracking: Change tracking support
- ✅ Custom XML: Custom XML parts
- ✅ Template Support: Document templates
- Clean Architecture: Follow the established pattern (domain → internal → pkg)
- Interfaces First: Define interfaces in
domain/, implementations ininternal/ - Error Handling: All public methods return errors
- Naming: Use clear, descriptive names
- Comments: Document all exported functions
- Tests: Aim for 95%+ coverage (current standard)
When contributing code:
- Domain Layer (
domain/) - Interfaces only, no implementations - Internal Layer (
internal/) - Core implementations, managers, services - Package Layer (
pkg/) - Public utilities, helpers, constants - No
interface{}- Use concrete types or generic constraints - Dependency Injection - Pass dependencies via constructors
- Thread-Safe - Use mutexes/atomics where needed
- Consider if it exists in v2 too
- Fix in both if applicable
- Mark PR with
legacy-v1label
Run tests before submitting:
go test ./... # Run all tests
go test -v ./... # Verbose output
go test -cover ./... # With coverage
go test -race ./... # Race detectionAfter regenerating any .docx fixtures (especially under examples/), validate them with the local Open XML validator to be sure Microsoft Word will open them without warnings:
dotnet run --project DocxValidator -- examples/07_advanced/07_advanced_demo.docxThe validator project targets .NET 8 and reports schema errors inline. Fix any reported issues before opening a pull request.
Update documentation when adding features:
- API Reference in README.md
- Inline code comments
- Example usage in demo files
- Update CHANGELOG if significant
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions or share ideas in GitHub Discussions
- Code of Conduct: Be respectful and constructive
If you have questions about contributing:
- Check existing issues and PRs
- Read the documentation in README.md
- Open a discussion or issue
Thank you for contributing to go-docx! 🎉