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

GetReport: Optionally accept a buffer size. #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

octo
Copy link

@octo octo commented May 25, 2020

This implementation uses Functional Options to keep the argument optional while allowing for adding more options in a backwards compatible way. Most existing uses should continue to work, because the new argument is optional. Code that uses an interface such as

type ReportGetter interface{
  GetReport(int) ([]byte, error)
}

will need to be updated though.

I tired striking a good balance between a small API surface and future extensibility. If you'd rather solve this differently, let me know and I'll happily reword the change.

Best regards,
—octo

This implementation uses "Functional Options" [0] to keep the argument
optional while allowing for adding more options in a backwards
compatible way. Most existing uses should continue to work, because the
new argument is optional. Code that uses an interface such as

    type ReportGetter interface{
        GetReport(int) ([]byte, error)
    }

will need to be updated though.

[0] https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
@octo octo force-pushed the getreport-buffer-size branch from 5485e23 to 3352c3b Compare May 25, 2020 18:30
@octo octo mentioned this pull request Jun 26, 2021
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.

1 participant