title: Golang net package mocking
body: <p>I'm trying to learn to write tests in golang on a personal project of mine.</p>
  
  <p>Bunch of the functions in my project are using <code>net</code> package, however since I'm new to this I don't know how to mock the functions from packages such as <code>net</code> one which are interacting with the host's devices.</p>
  
  <p>To make my question more concrete, I have a function similar to this:</p>
  
  <pre><code>func NewThingy(ifcName string) (*Thingy, error) {
      if ifc, err := net.InterfaceByName(ifcName); err == nil {
          return nil, fmt.Errorf("Interface name %s already assigned on the host", ifcName)
      }
  
      ....
  
      return &amp;Thingy{
          ifc: ifc,
      }, nil
  }
  </code></pre>
  
  <p>Thingy is clearly defined as:</p>
  
  <pre><code>type Thingy struct {
    ifc *net.Interface
  }
  </code></pre>
  
  <p>Anyone could give me any hints how to go about testing code like this ?</p>
  
  <p>Thanks</p>