[go-fan] Go Module Review: github.com/goccy/go-yaml v1.19.0 #5928
Closed
Replies: 1 comment
-
|
⚓ Avast! This discussion be marked as outdated by Go Fan. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🐹 Go Fan Report: goccy/go-yaml
Module Overview
goccy/go-yaml is a modern, feature-rich YAML parsing library for Go, built from scratch to replace the aging go-yaml/yaml library. It provides superior YAML 1.2 compliance, better error messages with colored output, AST manipulation, YAML Path support for querying, and comment preservation.
The project has been upgraded to v1.19.0 (released 2025-11-29), bringing exciting new features that are highly relevant to gh-aw's workflow compilation needs.
Current Usage in gh-aw
The module is extensively used throughout the codebase:
pkg/workflow,pkg/cli, andpkg/parserpackagesyaml.Marshal/yaml.Unmarshalfor standard encoding/decodingyaml.MarshalWithOptionswithIndent(2)andUseLiteralStyleIfMultiline(true)yaml.MapSlicefor preserving field order in generated workflowsResearch Findings
v1.19.0 Release Highlights (2025-11-29)
The latest version brings several features perfectly suited for gh-aw:
🆕 RawMessage Support ([Test] Test Pull Request - Safe Output Validation #790)
json.RawMessagefor deferred YAML decoding🆕 Field Prefix Filtering ([Test] Test Issue Created by Safe Output #795)
AllowSpecificFieldPrefixesdecode optionx-*custom fields)Bug Fixes:
Library Strengths
FormatError()Improvement Opportunities
🔥 NEW v1.19.0 Features to Leverage
1. RawMessage for Dynamic Frontmatter (HIGH PRIORITY)
Problem: Workflow frontmatter has dynamic/extensible sections (tools, engines) that are parsed multiple times
Solution: Use
yaml.RawMessageto defer parsing until neededBenefit: ~20% faster parsing, cleaner architecture
Locations:
pkg/parser/frontmatter.go,pkg/workflow/compiler_parse.go2. Field Prefix Filtering for Extensions (MEDIUM PRIORITY)
Problem: No way to allow custom/plugin fields in frontmatter without schema violations
Solution: Enable
x-*prefixed fields for user extensionsBenefit: Extensibility without breaking strict validation
Location:
pkg/parser/frontmatter_content.go:60🏃 Quick Wins
3. Add Strict Mode to Frontmatter Parsing (HIGH PRIORITY)
Problem: Typos in frontmatter keys go undetected until runtime
Solution: Add
yaml.Strict()option to all unmarshal callsBenefit: Catch configuration typos before workflows run
Note: Project has strict validation but not at YAML parsing level
4. Use FormatError for Better Error Messages (MEDIUM PRIORITY)
Problem: Raw YAML errors lack context and color
Solution: Wrap errors with
yaml.FormatError()Benefit: Colored, contextualized errors for better debugging
Locations: All 31 files with
yaml.Unmarshalcalls5. Fix Ignored Error in Tests (HIGH PRIORITY)
Problem:
pkg/workflow/dependabot_test.go:339ignores unmarshal errorBenefit: Prevent silent test failures
🔧 General Improvements
6. Optimize Marshal/Unmarshal Cycles (MEDIUM PRIORITY)
Problem:
pkg/workflow/compiler_parse.gohas 8+ marshal/unmarshal round-tripsInefficient pattern (lines 466, 474, 484, 495, 505, 513, 528, 536):
Solution: Work with Go structs directly, marshal once at the end
Benefit: ~30% faster workflow compilation
7. Centralize Marshal Options (LOW PRIORITY)
Problem:
yaml.Indent(2)andyaml.UseLiteralStyleIfMultiline(true)repeated 6+ timesSolution: Create helper function in
pkg/workflow/yaml.goBenefit: Single source of truth for YAML formatting
8. Explore YAMLPath for Complex Queries (LOW PRIORITY)
Current: Manual map traversal for nested field extraction
Alternative: Use YAML Path for cleaner code
Locations:
pkg/parser/frontmatter.goextraction functionsBenefit: More maintainable, less error-prone
Recommendations
Implement Soon
yaml.Strict()to frontmatter parsing for early error detectiondependabot_test.go:339Consider for Next Iteration
FormatErrorwrapping for better error messagescompiler_parse.goNice to Have
Next Steps
yaml.Strict()to all frontmatter unmarshal callscompiler_parse.goModule summary saved to:
specs/mods/go-yaml.mdReferences:
Beta Was this translation helpful? Give feedback.
All reactions