Adds `actionlint` to the pre-commit configuration to validate GitHub Actions workflows. Significantly expands the `AGENTS.md` file with a comprehensive summary of new features and changes in Go 1.24 and 1.25, along with actionable recommendations for the project. Additionally, normalizes markdown list formatting across various documentation files for consistency.
13 KiB
Agent Guidelines for articulate-parser
Build/Test Commands
- Build:
task buildorgo build -o bin/articulate-parser main.go - Run tests:
task testorgo test -race -timeout 5m ./... - Run single test:
go test -v -race -run ^TestName$ ./path/to/package - Test with coverage:
task test:coverageorgo test -race -coverprofile=coverage/coverage.out -covermode=atomic ./...
- Lint:
task lint(runs vet, fmt check, staticcheck, golangci-lint) - Format:
task fmtorgofmt -s -w . - CI checks:
task ci(deps, lint, test with coverage, build)
Code Style Guidelines
Imports
- Use
goimportswith local prefix:github.com/kjanat/articulate-parser - Order: stdlib, external, internal packages
- Group related imports together
Formatting
- Use
gofmt -s(simplify) andgofumptwith extra rules - Function length: max 100 lines, 50 statements
- Cyclomatic complexity: max 15
- Cognitive complexity: max 20
Types & Naming
- Use interface-based design (see
internal/interfaces/) - Export types/functions with clear godoc comments ending with period
- Use descriptive names:
ArticulateParser,MarkdownExporter - Receiver names: short (1-2 chars), consistent per type
Error Handling
- Always wrap errors with context:
fmt.Errorf("operation failed: %w", err) - Use
%wverb for error wrapping to preserve error chain - Check all error returns (enforced by
errcheck) - Document error handling rationale in defer blocks when ignoring close errors
Comments
- All exported types/functions require godoc comments
- End sentences with periods (
godotlinter enforced) - Mark known issues with TODO/FIXME/HACK/BUG/XXX
Security
- Use
#nosecwith justification for deliberate security exceptions (G304 for CLI file paths, G306 for export file permissions) - Run
gosecandgovulncheckfor security audits
Testing
- Enable race detection:
-raceflag - Use table-driven tests where applicable
- Mark test helpers with
t.Helper() - Benchmarks in
*_bench_test.go, examples in*_example_test.go
Dependencies
- Minimal external dependencies (currently: go-docx, golang.org/x/net, golang.org/x/text)
- Run
task deps:tidyafter adding/removing dependencies
Go 1.24 & 1.25 New Features Reference
This project uses Go 1.24+. Below is a comprehensive summary of new features and changes in Go 1.24 and 1.25 that may be relevant for development and maintenance.
Go 1.24 Major Changes (Released February 2025)
Language Features
Generic Type Aliases
- Type aliases can now be parameterized with type parameters
- Example:
type List[T any] = []T - Can be disabled via
GOEXPERIMENT=noaliastypeparams(removed in 1.25)
Tooling Enhancements
Module Tool Dependencies
- New
tooldirective in go.mod tracks executable dependencies - Use
go get -tool <package>to add tool dependencies - Use
go install toolandgo get toolto manage them - Eliminates need for blank imports in
tools.gofiles
Build Output Formatting
- Both
go buildandgo testsupport-jsonflag for structured JSON output - New action types distinguish build output from test results
Authentication
- New
GOAUTHenvironment variable provides flexible authentication for private modules
Automatic Version Tracking
go buildautomatically sets main module version in binaries based on VCS tags- Adds
+dirtysuffix for uncommitted changes
Cgo Performance Improvements
- New
#cgo noescapeannotation: Prevents escape analysis overhead for C function calls - New
#cgo nocallbackannotation: Indicates C function won't call back to Go
Toolchain Tracing
GODEBUG=toolchaintrace=1enables tracing of toolchain selection
Runtime & Performance
Performance Improvements
- 2-3% CPU overhead reduction across benchmark suites
- New Swiss Tables-based map implementation (faster lookups)
- Disable via
GOEXPERIMENT=noswissmap
- Disable via
- More efficient small object allocation
- Redesigned runtime-internal mutexes
- Disable via
GOEXPERIMENT=nospinbitmutex
- Disable via
Compiler & Linker
Method Receiver Restrictions
- Methods on cgo-generated types now prevented (both directly and through aliases)
Build IDs
- Linkers generate GNU build IDs (ELF) and UUIDs (macOS) by default
- Disable via
-B noneflag
Standard Library Additions
File System Safety - os.Root
- New
os.Roottype enables directory-limited operations - Prevents path escape and symlink breakouts
- Essential for sandboxed file operations
Cryptography Expansion
crypto/mlkem: ML-KEM-768/1024 post-quantum key exchange (FIPS 203)crypto/hkdf: HMAC-based Extract-and-Expand KDF (RFC 5869)crypto/pbkdf2: Password-based key derivation (RFC 8018)crypto/sha3: SHA-3 and SHAKE functions (FIPS 202)
FIPS 140-3 Support
- New
GOFIPS140environment variable enables FIPS mode - New
fips140GODEBUG setting for cryptographic module compliance
Weak References - weak Package
- New
weakpackage provides low-level weak pointers - Enables memory-efficient structures like weak maps and caches
- Useful for preventing memory leaks in cache implementations
Testing Improvements
testing.B.Loop(): Cleaner syntax replacing manualb.Niteration- Prevents compiler from optimizing away benchmarked code
- New
testing/synctestpackage (experimental) for testing concurrent code with fake clocks
Iterator Support
- Multiple packages now offer iterator-returning variants:
bytes: Iterator-based functionsstrings: Iterator-based functionsgo/types: Iterator support
Security Enhancements
TLS Post-Quantum Cryptography
X25519MLKEM768hybrid key exchange enabled by default in TLS- Provides quantum-resistant security
Encrypted Client Hello (ECH)
- TLS servers can enable ECH via
Config.EncryptedClientHelloKeys - Protects client identity during TLS handshake
RSA Key Validation
- Keys smaller than 1024 bits now rejected by default
- Use
GODEBUG=rsa1024min=0to revert (testing only)
Constant-Time Execution
- New
crypto/subtle.WithDataIndependentTiming()enables architecture-specific timing guarantees - Helps prevent timing attacks
Deprecations & Removals
runtime.GOROOT(): Deprecated; use system path insteadcrypto/cipherOFB/CFB modes: Deprecated (unauthenticated encryption)x509sha1GODEBUG: Removed; SHA-1 certificates no longer verified- Experimental
X25519Kyber768Draft00: Removed
Platform Changes
- Linux: Now requires kernel 3.2+ (enforced)
- macOS: Go 1.24 is final release supporting Big Sur
- Windows/ARM 32-bit: Marked broken
- WebAssembly:
- New
go:wasmexportdirective - Reactor/library builds supported via
-buildmode=c-shared
- New
Bootstrap Requirements
- Go 1.24 requires Go 1.22.6+ for bootstrapping
- Go 1.26 will require Go 1.24+
Go 1.25 Major Changes (Released August 2025)
Language Changes
- No breaking language changes
- "Core types" concept removed from specification (replaced with clearer prose)
Tooling Improvements
Go Command Enhancements
go build -asan: Now defaults to leak detection at program exit- New
go.mod ignoredirective: Specify directories for go command to ignore go doc -http: Starts documentation server and opens in browsergo version -m -json: Prints JSON-encoded BuildInfo structures- Module path resolution now supports subdirectories using
<meta>syntax - New
workpackage pattern matches all packages in work/workspace modules - Removed automatic toolchain line additions when updating
goversion
Vet Analyzers
- "waitgroup": Detects misplaced
sync.WaitGroup.Addcalls - "hostport": Warns against using
fmt.Sprintffor constructing addresses- Recommends
net.JoinHostPortinstead
- Recommends
Runtime Enhancements
Container-Aware GOMAXPROCS
- Linux now respects cgroup CPU bandwidth limits
- All OSes periodically update GOMAXPROCS if CPU availability changes
- Disable via environment variables or GODEBUG settings
- Critical for containerized applications
New Garbage Collector - "Green Tea GC"
- Experimental
GOEXPERIMENT=greenteagcenables new GC - 10-40% reduction in garbage collection overhead
- Significant for GC-sensitive applications
Trace Flight Recorder
- New
runtime/trace.FlightRecorderAPI - Captures execution traces in in-memory ring buffer
- Essential for debugging rare events and production issues
Other Runtime Changes
- Simplified unhandled panic output
- VMA names on Linux identify memory purpose (debugging aid)
- New
SetDefaultGOMAXPROCSfunction resets GOMAXPROCS to defaults
Compiler Fixes & Improvements
Critical Nil Pointer Bug Fix
- Fixed Go 1.21 regression where nil pointer checks were incorrectly delayed
- ⚠️ May cause previously passing code to now panic (correct behavior)
- Review code for assumptions about delayed nil checks
DWARF5 Support
- Debug information now uses DWARF version 5
- Reduces binary size and linking time
- Better debugging experience
Faster Slices
- Expanded stack allocation for slice backing stores
- Improved slice performance
Linker
- New
-funcalign=Noption specifies function entry alignment
Standard Library Highlights
New Packages
-
testing/synctest(Promoted from Experimental)- Concurrent code testing with virtualized time
- Control time progression in tests
- Essential for testing time-dependent concurrent code
-
encoding/json/v2(Experimental)- Substantially better decoding performance
- Improved API design
- Backward compatible with v1
Major Package Updates
| Package | Key Changes |
|---|---|
crypto |
New MessageSigner interface and SignMessage function |
crypto/ecdsa |
New raw key parsing/serialization functions |
crypto/rsa |
Key generation now 3x faster |
crypto/sha1 |
Hashing 2x faster on amd64 with SHA-NI |
crypto/tls |
New CurveID field; SHA-1 algorithms disallowed in TLS 1.2 |
net |
Windows now supports file-to-connection conversion; IPv6 multicast improvements |
net/http |
New CrossOriginProtection middleware for CSRF defense |
os |
Windows async I/O support; Root type expanded with 12 new methods |
sync |
New WaitGroup.Go method for convenient goroutine creation |
testing |
New Attr, Output methods; AllocsPerRun panics with parallel tests |
unique |
More eager and parallel reclamation of interned values |
Performance Notes
Performance Improvements
- ECDSA and Ed25519 signing 4x faster in FIPS 140-3 mode
- SHA3 hashing 2x faster on Apple M processors
- AMD64 fused multiply-add instructions in v3+ mode
- ⚠️ Changes floating-point results (within IEEE 754 spec)
Performance Regressions
- SHA-1, SHA-256, SHA-512 slower without AVX2
- Most servers post-2015 support AVX2
Platform Changes
- macOS: Requires version 12 Monterey or later
- Windows: 32-bit windows/arm port marked for removal in Go 1.26
- Loong64: Race detector now supported
- RISC-V:
- Plugin build mode support
- New
GORISCV64=rva23u64environment variable value
Deprecations
go/astfunctions:FilterPackage,PackageExports,MergePackageFilesgo/parser.ParseDirfunction- Old
testing/synctestAPI (whenGOEXPERIMENT=synctestset)
Actionable Recommendations for This Project
Immediate Opportunities
-
Replace
sync.WaitGrouppatterns withWaitGroup.Go()(Go 1.25)// Old pattern wg.Add(1) go func() { defer wg.Done() // work }() // New pattern (Go 1.25) wg.Go(func() { // work }) -
Use
testing.B.Loop()in benchmarks (Go 1.24)// Old pattern for i := 0; i < b.N; i++ { // benchmark code } // New pattern (Go 1.24) for b.Loop() { // benchmark code } -
Consider
os.Rootfor file operations (Go 1.24)- Prevents path traversal vulnerabilities
- Safer for user-provided file paths
-
Enable Green Tea GC for testing (Go 1.25)
- Test with
GOEXPERIMENT=greenteagc - May reduce GC overhead by 10-40%
- Test with
-
Leverage container-aware GOMAXPROCS (Go 1.25)
- No changes needed; automatic in containers
- Improves resource utilization
-
Review floating-point operations (Go 1.25)
- AMD64 v3+ uses FMA instructions
- May change floating-point results (within spec)
-
Watch nil pointer checks (Go 1.25)
- Compiler bug fix may expose latent nil pointer bugs
- Review crash reports carefully
Future Considerations
-
Evaluate
encoding/json/v2when stable- Better performance for JSON operations
- Currently experimental in Go 1.25
-
Adopt tool directives in go.mod
- Cleaner dependency management for build tools
- Remove
tools.goif present
-
Enable FIPS mode if required
- Use
GOFIPS140=1for compliance - Performance improvements in Go 1.25 (4x faster signing)
- Use
-
Use
runtime/trace.FlightRecorderfor production debugging- Capture traces of rare events
- Minimal overhead when not triggered