httptest.ResponseRecorder has no field or method Result
<p>So this one is really weird, I'm trying to get a mock response that renders JSON. My test looks like this:</p>

<pre><code>import (
    "fmt"
    "net/http"
    "net/http/httptest"
    "reflect"
    "strings"
    "testing"
)
...

func TestMessageFromResponse(t *testing.T) {
    mc := MyController{}
    body := "{ \"message\":\"kthxbai\" }"
    w := httptest.NewRecorder()
    w.Write([]byte(body))
    resp := w.Result()
    msg := mc.messageFromResponse(resp)
    if msg != "kthxbai" {
        t.Errorf("Expected response body to be kthxbai but was %s", msg)
    }
}
</code></pre>

<p>I'm testing the method <code>messageFromResponse</code> on <code>MyController</code>but its not even building. When I run <code>go test</code> in my project directory, I get the following error:</p>

<pre><code>./my_controller_test.go:115: w.Result undefined (type *httptest.ResponseRecorder has no field or method Result)
</code></pre>

<p>I should also mention that I am successfully using <code>httptest.ResponseRecorder</code> as a writer stub elsewhere in this same file, but it's just failing when I try to access <code>Result()</code>.</p>