On Thu, 1 Aug 2019 05:09:54 -0700 (PDT)
Nitish Saboo <[email protected]> wrote:
> Hi,
>
> How can we mock a function in Go like os.Hostname() or os.Getwd() ?
> Any framework or Library that we can use for mocking the function
> calls ?
>
I usually does something like these,
var getHostname = os.Hostname
and in test file,
getHostname = func() {
return "something", nil // or a variable
}
--
{ "github":"github.com/shuLhan", "site":"kilabit.info" }
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/20190801214848.00e217cb%40kilabit.local.