Replies: 2 comments 4 replies
-
Note: the proposed solution currently raises a golangci-lint error (golangci-lint 2.1.6): However this is a false positive that I've reported in mgechev/revive#1406 and that already has a proposed fix in mgechev/revive#1407. |
Beta Was this translation helpful? Give feedback.
4 replies
-
Closing the discussion for lack of feedback. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Many packages under
contrib/
expose constructors that use the functional options pattern. Each package expose anOption
type as well as anOptionFn
type. HoweverOptionFn
is just an implementation detail that should never have been exposed.This is a proposal to refactor the implementation of those
Option
types in a source compatible way that will be transparent to users. This refactor deprecates theOptionFn
type (which no user should have ben using becauseOption
is the abstract type) to go towards its removal in the future.This refactor also allows to use a lighter implementation of the functional options pattern that hides implementation details via private types and type aliases, and uses only concrete types avoiding applying options through a (private) interface.
Implementation
Before:
After:
This could be refactored further by changing how options are applied in the contructor by completely bypassing the
apply(*config)
method:Before:
After:
Beta Was this translation helpful? Give feedback.
All reactions