Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplified import logic #20

Closed
wants to merge 2 commits into from
Closed

simplified import logic #20

wants to merge 2 commits into from

Conversation

SustainedCruelty
Copy link

I simplified some of the code for importing json and yaml files.
Instead of saving the flags before unmarshalling, we can simply parse the flags again after we've read in the file.

main.go Outdated
if err = json.NewDecoder(f).Decode(&file); err != nil {
return err
}
} else if strings.HasSuffix(importPath, ".yaml") && strings.HasSuffix(importPath, ".yml") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line requires both the .yml tag and the .yaml tag.
It should be or

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @hopefulTex!

main.go Outdated Show resolved Hide resolved
@hopefulTex
Copy link
Contributor

How does this work? If the flags aren't parsed until after the import file is read then how does the program know what the import path flag is set to?
Does it parse internally and the .Parse() call just does so again?

@SustainedCruelty SustainedCruelty closed this by deleting the head repository Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants