Merged
Conversation
* prefer `figtree:"name=value"` tag for field names. * prevent duplicate conflicts between yaml names and struct field names.
aaronlehmann
approved these changes
Jun 19, 2025
figtree.go
Outdated
Comment on lines
564
to
566
| case aOk && bOk: | ||
| // if both defined, pick the first one | ||
| resultTag = append(resultTag, fmt.Sprintf("%s:%q", tag, aTag)) |
Collaborator
There was a problem hiding this comment.
This seems redundant with case aOk below
figtree.go
Outdated
| if prev, ok := seen[value.Name]; ok { | ||
| // we have a duplicate field name, this should not happen | ||
| // but if it does, we will just skip it | ||
| fmt.Fprintf(os.Stderr, "Duplicate field name %q in merge struct.\n\tOld: %s %s `%s`\n\tNew: %s %s `%s`\n", value.Name, prev.Name, prev.Type.String(), prev.Tag, value.Name, value.Type.String(), value.Tag) |
Collaborator
There was a problem hiding this comment.
Is this debugging code? Not sure we want figtree to print to os.Stderr on its own accord. I'd suggest either:
- A panic if this shouldn't be possible to trigger
- Silently ignored if it can happen but isn't actionable
- Pass in a logger if it's something we want to bubble up non-fatally
Owner
Author
There was a problem hiding this comment.
I ended up converting these to panics. The reflect.MakeStruct call will panic below if we have duplicate fields, so better to panic here with slightly friendlier output.
figtree.go
Outdated
| if prev, ok := yamlSeen[yamlName]; yamlName != "" && ok { | ||
| // we have a duplicate field name, this should not happen | ||
| // but if it does, we will just skip it | ||
| fmt.Fprintf(os.Stderr, "Duplicate YAML tag %q in merge struct.\n\tOld: %s %s `%s`\n\tNew: %s %s `%s`\n", yamlName, prev.Name, prev.Type.String(), prev.Tag, value.Name, value.Type.String(), value.Tag) |
Collaborator
There was a problem hiding this comment.
Same concern about printing to stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optiontypes, select the type that both merge types are assignable to (ieOption[string]vsOption[any],Option[any]will be chosen).figtree:"name=value"tag for field names.