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
pila: allow publicly to use custom Stack implementation #47
Conversation
This commit does not imply API breaking changes changes. Now it is possible to create a `pila.Stack` using a custom implementation that satisfies the `stack.Stacker` interface, e.g. ```go type TestStack struct{} func (s *TestStack) Push(element interface{}) { return } func (s *TestStack) Pop() (interface{}, bool) { return nil, false } func (s *TestStack) Size() int { return 0 } func (s *TestStack) Peek() interface{} { return nil } func (s *TestStack) Flush() { return } stack := pila.NewStackWithCustomImplementation("stack", time.Now(), &TestStack{}) ```
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 18 18
Lines 660 664 +4
=====================================
+ Hits 660 664 +4
Continue to review full report at Codecov.
|
Thanks @javierprovecho for the feedback on this subject. Feel free to review the changes. |
pila/stack.go
Outdated
|
||
// NewStackWithCustomImplementation creates a new Stack given a name, a creation date, | ||
// and a stack.Stacker implementation without an association to any Database. | ||
func NewStackWithCustomImplementation(name string, t time.Time, stack stack.Stacker) *Stack { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe don't shadow stack package with stack argument, and rename it like impl
, s
or base
. You get the idea...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exactly had this thought when I named the parameter as stack
. So if a second mind think likewise, change the name it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javierprovecho thanks! we'll discuss about making public the |
This commit does not imply API breaking changes, so it can be added in the next
0.1.X release.
Now it is possible to create a
pila.Stack
using a customimplementation that satisfies the
stack.Stacker
interface, e.g.It is also possible to create a Stack with a custom base implementation from a Database instance: