title: Golang: Replace function unit testing
body: <p>I'm working with Golang, and currently I'm doing some fun unit test with <a href="https://github.com/stretchr/testify" rel="nofollow">Testify</a>, my file look like this</p>
  
  <pre><code>type myStruct struct {
    field_1 string
  
  }
  func (self *myStruct) writeFirst()  {
  //doing something
  //modify field_1
  self.writeSecond()
  }
  
  func (self *myStruct) writeSecond() {
  //doing something
  }
  </code></pre>
  
  <p>In this case I'm testing writeFirst() but I'm trying to replace writeSecond() because it is using http stuff that I don't want to use because it access to internet.</p>
  
  <p>I think that use a second struct and set myStruct as anonymous field will be the solution, but it's not working because me second struct and myStruct have a diferent context.</p>
  
  <p>In this case I can't use mocks cause  writeSecond is a method of the struct.</p>
  
  <p>My test case looks like this:</p>
  
  <pre><code>func TestWriteFirst(t *testing.T) {
     myStc := myStruct{}
     assert.Equal(t,"My response", myStc.field_1)
  }
  </code></pre>
  
  <p>All that I want is testing writeFirst without pass to writeSecond()</p>