Skip to content

Conversation

@goccy
Copy link
Owner

@goccy goccy commented Dec 23, 2024

resolve #461

yaml.UseAutoAnchor() option automatically assigns an anchor name to a value when the same pointer address is found during encoding and uses an alias for reference points

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 78.28571% with 38 lines in your changes missing coverage. Please review.

Project coverage is 77.19%. Comparing base (9cbf5d4) to head (d3d0468).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #606      +/-   ##
==========================================
- Coverage   77.21%   77.19%   -0.03%     
==========================================
  Files          22       22              
  Lines        7870     7966      +96     
==========================================
+ Hits         6077     6149      +72     
- Misses       1374     1393      +19     
- Partials      419      424       +5     
@bep
Copy link

bep commented Dec 23, 2024

@goccy This is a great option that I (and I suspect many others) would really want, I don't see how it fixes #461.

The printing problem I'm talking about isn't (just) marshaling it back to YAML. There's a lot of potential printing going on in Hugo. E.g. to JSON, or templates:

{{ range $k, $v := $frontmatter }}
   {{ printf "%s: %s" $k $v }}
{{ end }}

So what I had in mind was an option to detect malicious/insensible YAML documents and throw an error. I have reopened the upstream PR about this gohugoio/hugo#13033 -- I'm thinking it should be possible to add some "sanity checks" on the unmarshaled Go map.

But again, an auto anchor option is still a great idea.

@goccy
Copy link
Owner Author

goccy commented Feb 16, 2025

This feature has already been supported by #662 , so close this PR.

@goccy goccy closed this Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants