title: How to check a log/output in go test?
body: <p>I have this function that logs the error in some cases:</p>
  
  <pre><code>func readByte(/*...*/){
      // ...
      if err != nil {
          fmt.Println("ERROR")
          log.Print("Couldn't read first byte")
          return
      }
      // ...
  }
  </code></pre>
  
  <p>Now, in the test file, I want to check the output error from this function:</p>
  
  <pre><code>    c.Assert(OUTPUT, check.Matches, "teste")
  </code></pre>
  
  <p>How can I access the log? I tried to put a buffer but it didn't work. What is the right way to catch this log without change my readByte function code?</p>