I would suggest to use *function as type* and replace it at the run time
For more info visit these link:
https://gist.github.com/husobee/9ff87a6f27e9abb4a3bc

// now a patch example
> oldDoSomething := doSomething
> // reset func after completing method
> *defer func () { doSomething = oldDoSomething}()*
> doSomething = func(s SomethingInterface) bool {
> return true
> }


You can use delegation approach as mentioned here:
https://stackoverflow.com/questions/59693971/mocked-method-not-working-in-golang-while-running-the-test-cases/59704965#59704965

Hope this helps.






On Sun, 12 Jan, 2020, 11:46 PM Ori Newman, <orinewm...@gmail.com> wrote:

> Hi,
> I know https://github.com/bouk/monkey , but it has a very restrictive
> license (it says "I do not give anyone permissions to use this tool for any
> purpose. Don't use it.").
> Someone knows an alternative with a better license?
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/9ef764d2-060d-4451-b1d9-034285e524ee%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/9ef764d2-060d-4451-b1d9-034285e524ee%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALLXM4D1SKwMMyoD0Tci1p0%2BQexf1hg48-O9JYnyasNQF3nQ7Q%40mail.gmail.com.

Reply via email to