All notable changes to v2 will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Complete Phase 10: Document Reading to 100%
- Read headers/footers from existing documents
- Read images from existing documents
- Comments and change tracking
This is the first stable, production-ready release of go-docx v2!
- OpenDocument() - Open and read existing .docx files
- Document parsing - Parse document structure (paragraphs, runs, tables)
- Content modification - Edit existing text, formatting, and table cells
- Style preservation - Maintains all paragraph styles (Title, Subtitle, Heading1-9, Quote, Normal, ListParagraph)
- Content addition - Add new paragraphs, runs, and sections to existing documents
- Round-trip workflow - Create → Save → Open → Modify → Save
- Example 12 - Complete read/modify example with documentation
- Fixed style preservation - Paragraph styles now correctly preserved when reading documents (Oct 29, 2025)
- Added
applyParagraphStyle()function ininternal/reader/reconstruct.go - Extracts
w:pStylefrom paragraph properties and applies viapara.SetStyle() - All paragraph styles (Title, Subtitle, Heading1-3, Quote, Normal, ListParagraph) now working
- Added
- Enhanced example 12 - Now demonstrates both editing existing content AND adding new content
- Fixed README Quick Start - Corrected all API examples to show accurate signatures
- Separated Simple API vs Builder API clearly
- Fixed
WithDefaultFont()andWithDefaultFontSize()signatures - Corrected page size constant (
docx.A4notdocx.PageSizeA4) - Fixed alignment constant (
domain.AlignmentCenternotdocx.AlignmentCenter) - Added new Option 3: Read and Modify Existing Documents
- Updated example count - All documentation now references 11 working examples (was 9)
- Updated Phase 10 status - Marked as "60% complete - core features working" (was "Not Started")
- Fixed error handling examples - Corrected builder pattern usage in README
3a0832a- docs: fix README Quick Start with correct API examples and update status19c0e73- Update documentation: Phase 10 now 60% complete with working readerca7f1f1- Fix: Preserve paragraph styles when reading documents3289b54- Enhance example 12: Add content editing capabilities852c3bf- Add example 12: Read and modify documents497a94a- Fix strict OOXML validation and update docs to beta-ready status
-
Core Interfaces (domain package)
Documentinterface with metadata supportParagraphinterface with full formatting optionsRuninterface for character-level formattingTable,TableRow,TableCellinterfacesSection,Header,FooterinterfacesStyleandFieldinterfaces
-
Core Implementations (internal/core)
document- Document implementation with validationparagraph- Paragraph with alignment, indentation, spacingrun- Text run with bold, italic, color, font, sizetable,tableRow,tableCell- Full table support
-
Service Managers (internal/manager)
IDGenerator- Thread-safe ID generation with atomic countersRelationshipManager- OOXML relationship managementMediaManager- Media file (images) management
-
Utilities (pkg)
errorspackage - Structured error typesDocxErrorwith operation and error codesValidationErrorfor input validationBuilderErrorfor fluent API error propagation
constantspackage - OOXML constants- Measurement conversions (twips, EMUs, points)
- Default capacities for performance
- OOXML namespaces and relationship types
- Content types and file paths
- Validation limits
colorpackage - Color utilitiesFromHex()- Parse hex color stringsToHex()- Convert to hex strings
-
Examples
- Basic example demonstrating v2 API usage
- Shows paragraph, run, table creation
- Demonstrates formatting and validation
-
Tests
- Comprehensive unit tests for core package
- Tests for validation logic
- Table operations tests
- 95%+ code coverage
- Clean Architecture: Separation of domain (interfaces), internal (implementations), pkg (utilities)
- Interface-Based: All domain entities are interfaces for testability
- Dependency Injection: No global state, managers injected
- Error Handling: All methods return errors, no silent failures
- Type Safety: No
interface{}, strong typing throughout - Thread Safety: Managers use mutexes and atomic operations
- Validation: All inputs validated before use
- Immutability: Defensive copies returned from getters
- Pre-allocated slices with capacity hints
- Thread-safe atomic counters (no mutex overhead for IDs)
- Lazy loading of relationships and media
- Efficient string building for text extraction
- Complete API rewrite
- All methods now return errors
- Interface-based design (vs. concrete types)
- Different package structure
- No global document state
- Validation required on all inputs
- Different naming conventions
First alpha release of v2.
- ✅ Core domain interfaces defined
- ✅ Basic implementations working
- ✅ Service managers implemented
- ✅ Error handling system in place
- ✅ Constants and utilities ready
- ✅ Tests passing (95%+ coverage)
- 🚧 XML serialization (pending)
- 🚧 File I/O (pending)
- 🚧 Builder pattern (pending)
- Cannot save/load .docx files yet (serialization pending)
- Sections not fully implemented
- Fields (TOC, page numbers) not implemented
- Images/drawings not implemented
- No migration guide from v1 yet
- Implement XML serialization
- Add file I/O support
- Complete sections implementation
- Add builder pattern for fluent API
- Create migration guide
- v2.0.0-alpha: Initial pre-release (Phase 1 complete)
- v1.0.0: Legacy version (separate branch)
v2 is a complete rewrite and is not backward compatible with v1.
Key Differences:
| v1 | v2 |
|---|---|
| Concrete types | Interfaces |
| Silent failures | Error returns |
| Global state | Dependency injection |
| No validation | Full validation |
| Magic numbers | Named constants |
unsafe.Pointer |
Safe conversions |
| Chinese strings | English constants |
See full migration guide (coming soon): docs/MIGRATION.md
- Original v1: Various contributors
- v2 Clean Architecture Rewrite: Misael Monterroca team (2025)
AGPL-3.0 - See LICENSE file