On Thu, 1 Aug 2019 05:09:54 -0700 (PDT)
Nitish Saboo <nitish.sabo...@gmail.com> 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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20190801214848.00e217cb%40kilabit.local.

Reply via email to