func TestMyHandler(t *testing.T) { // Set up a mock server server := ghttp.NewServer() defer server.Close() // Send a request to the server resp, err := http.Get(server.URL() + "/my/path") if err != nil { t.Fatal(err) } // Verify that the server received the request requests := server.ReceivedRequests() if len(requests) != 1 { t.Fatalf("Expected 1 request, got %d", len(requests)) } // Verify details about the request req := requests[0] if req.Method != "GET" { t.Errorf("Expected GET method, got %s", req.Method) } if req.URL.Path != "/my/path" { t.Errorf("Expected path '/my/path', got '%s'", req.URL.Path) } // Verify the response if resp.StatusCode != http.StatusOK { t.Errorf("Expected status 200, got %d", resp.StatusCode) } }In this example, we set up a mock server using ghttp.NewServer(), and then send a request to that server using http.Get(). We then use server.ReceivedRequests() to inspect the request that the mock server received, and make assertions about that request (e.g. that it has the correct method and path). Finally, we make assertions about the response returned by the server. This functionality is part of the ghttp package library, which is designed to help test HTTP servers in Go.