You don't need to change the original function. Below, Fib(int) int is
the original function, and it illustrates two ways to decorate it.
https://play.golang.org/p/K6us_rHIsyM
Neither is a *bad* way to write code. Go is a different language so
some things you're used to in other languages must be done in
different ways. This sometimes requires you to re-engineer your
solution. So trying to replicate a Java decorator pattern
implementation in Go using Java features won't work. Change the way
you're trying to solve your problem.
You use decorators to make existing code fit another scenario. For
this to work, the receiving end of the problem must be able to handle
such decoration as well. If you have code that uses the function `Fib`
directly, then you cannot override Fib. You cannot override Fib in
Java either (don't know about python). Your code should be able to get
an indirection of Fib (either an interface or a function pointer) so
you can override it.
> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/ad4658a5-c6a6-4cfb-ad48-95ce8ecbfa2b%40googlegroups.com.