title: Spying on methods in Golang
body: <p>Is there any way to spy on methods in Golang?</p>
  
  <p>For example, suppose I have </p>
  
  <pre><code>type Object struct { 
      A int
      B string
      C *interface{}
  }   
  
  func (o *Object) Something(val interface{}) {
      o.A = 102
      // some other business logic under test
  
      o.SomethingElse(o.C, val)
  }
  
  //...
  
  func (o *Object) Process(val interface{}) interface{} { 
      // some business logic
  
      return 43 // or something else. no me importa ya
  }
  
  //...
  
  func (o *Object) SomethingElse(iPtr *interface{}, val interface{}) { 
  
      processedVal := o.Process(val)
      if iPtr == nil { 
          iPtr = new(interface{})
      }
  
      *iPtr = val
  }
  </code></pre>
  
  <p>In writing a test against <code>Object.Something</code>, we should not need to care about what's happening in <code>SomethingElse</code> or the <code>Process</code> invoked from within. Is there any way, in Golang, to isolate these dependencies?</p>