ExampleSendJSON provides a basic example.
()
| 11 | |
| 12 | // ExampleSendJSON provides a basic example. |
| 13 | func ExampleSendJSON() { |
| 14 | r, _ := http.NewRequest("GET", "/sendjson", nil) |
| 15 | w := httptest.NewRecorder() |
| 16 | http.DefaultServeMux.ServeHTTP(w, r) |
| 17 | |
| 18 | var u struct { |
| 19 | Name string |
| 20 | Email string |
| 21 | } |
| 22 | |
| 23 | if err := json.NewDecoder(w.Body).Decode(&u); err != nil { |
| 24 | log.Println("ERROR:", err) |
| 25 | } |
| 26 | |
| 27 | fmt.Println(u) |
| 28 | // Output: |
| 29 | // {Bill bill@ardanstudios.com} |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected