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

Rethink Variadic arguments as optional parameters #19

Open
kardianos opened this issue Aug 8, 2023 · 1 comment
Open

Rethink Variadic arguments as optional parameters #19

kardianos opened this issue Aug 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@kardianos
Copy link

Right now in the file pkg, a number of constructor functions take a variadic arguments in place of an optional argument. I would recommend against such a practice; it isn't clear what the string array is for at first glance. I might suggest something like:

package file
type Option struct {
    Terminator string
}
// Option may be omitted.
func NewFile(InterchangeRule, opt *Option) {...}

Another method to capture this might be to create a Constructor type, with perhaps a default package level var constructor, where new files and methods are created from, with the options on them. Or maybe not.

@adamdecaf adamdecaf added the enhancement New feature or request label Aug 10, 2023
@adamdecaf
Copy link
Member

I agree. We should use structs to modify behavior. cc @mfdeveloper508

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants