Hi,
The attached gist can't work for patching methods. And I do not want to use 
dependency injection. This is a very big project and I'm beyond the point 
that I can change it to use dependency injection.

On Sunday, January 12, 2020 at 10:00:31 PM UTC+2, prakash sharma wrote:
>
>
> 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 
> <https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fhusobee%2F9ff87a6f27e9abb4a3bc&sa=D&sntz=1&usg=AFQjCNGVwV-osRRy0XuCRZcVqpkkp-OaMw>
>
> // 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, <orine...@gmail.com 
> <javascript:>> 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 golan...@googlegroups.com <javascript:>.
>> 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/00e4ae23-848e-4ebd-997f-49cb0e52b20f%40googlegroups.com.

Reply via email to