title: How to improve testing coverage in Go?
body: <p>I am doing some testing. I have a file dao.go:</p>
  
  <pre><code>package model_dao
  import "io/ioutil"
  const fileExtension = ".txt"
  type Page struct {
      Title string
      Body  []byte
  }
  func (p Page) SaveAsFile() (e error) {
      p.Title = p.Title + fileExtension
      return ioutil.WriteFile(p.Title, p.Body, 0600)
  }
  func LoadFromFile(title string) (*Page, error) {
      fileName := title + fileExtension
      body, err := ioutil.ReadFile(fileName)
      if err != nil {
          return nil, err
      }
      return &amp;Page{title, body}, nil
  }
  </code></pre>
  
  <p>And a test file dao_test.go:</p>
  
  <pre><code>package model_dao_test
  import (
      "shopserver/model/dao"
      "testing"
  )
  func TestDAOFileWorks(t *testing.T) {
      TITLE := "test"
      BODY := []byte("Hello, World!!")
      p := &amp;model_dao.Page{TITLE, BODY}
      p.SaveAsFile()
      p, _ = model_dao.LoadFromFile(TITLE)
      result := p.Body
      if string(BODY) != string(result) {
          t.Error("Body", BODY, "saved.\n", "Load:", result)
      }
  }
  </code></pre>
  
  <p>Here I test all 2 methods from <em>Page</em>, but after testing I see a message:</p>
  
  <p><a href="https://i.stack.imgur.com/CGF03.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CGF03.png" alt="enter image description here"></a></p>
  
  <p>Why do I only get 85.7%? Where he get this numbers and how to get 100%?</p>