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

Ensure all exported structs are usable as "zero value" #1775

Closed
5 tasks
Tracked by #833
meatballhat opened this issue Jun 21, 2023 · 3 comments · Fixed by #1972
Closed
5 tasks
Tracked by #833

Ensure all exported structs are usable as "zero value" #1775

meatballhat opened this issue Jun 21, 2023 · 3 comments · Fixed by #1972
Labels
area/v3 relates to / is being considered for v3
Milestone

Comments

@meatballhat
Copy link
Member

meatballhat commented Jun 21, 2023

This likely overlaps with the goal described in #1774, but this issue is intended to track a lower-level list of specific types. Each of these types must have tests in place to ensure the "zero value" is usable in the way it is documented. This may require softening the rule in some places, but I'd like such places to be accompanied with documentation and good examples of happy path usage. The critical parts of what I mean by "usable" are:

  • None of the functions with the struct as receiver or argument panic
  • None of the templates that use the struct panic or otherwise result in an error

I do not expect arbitrary, undocumented, or otherwise unsupervised usage of a "zero value" struct to fulfill these requirements. The primary way I expect the above definition of "usable" to be implemented is via private methods that ensure all fields are minimally initialized such as *Command.setupDefaults.

  • Ensure Command type is usable as "zero value"
  • Ensure ValueSourceChain type is usable as "zero value"
  • Ensure MutuallyExclusiveFlags type is usable as "zero value"
  • Ensure BoolWithInverseFlag type is usable as "zero value"
  • (more TODO)
@meatballhat meatballhat added this to the Release 3.x milestone Jun 21, 2023
@meatballhat meatballhat added the area/v3 relates to / is being considered for v3 label Apr 27, 2024
@bartekpacia
Copy link
Member

@meatballhat How do you imagine e.g. a zero-valued Command to work? I mean, at least a name is required so it will display correctly in "help" and will be triggered.

@meatballhat
Copy link
Member Author

@bartekpacia Hello and sorry for my delay! I'll add some more details to the description 👍🏼

@dearchap
Copy link
Contributor

@meatballhat Did you mean something like in the test cases in the PR ? The BoolWithInverseFlag is more tricky as it would involve having a

f != nil 

at the beginning of every function in FlagBase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v3 relates to / is being considered for v3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants