我试图调试我收到了一个简单的REST库我一个非常不寻常的错误中写道.
我使用标准的net/http包来制作Get,Post,Put,Delete请求,但是当我连续发出多个请求时,我的测试偶尔会失败.我的测试看起来像这样:
func TestGetObject(t *testing.T) {
firebaseRoot := New(firebase_url)
body, err := firebaseRoot.Get("1")
if err != nil {
t.Errorf("Error: %s", err)
}
t.Logf("%q", body)
}
func TestPushObject(t *testing.T) {
firebaseRoot := New(firebase_url)
msg := Message{"testing", "1..2..3"}
body, err := firebaseRoot.Push("/", msg)
if err != nil {
t.Errorf("Error: %s", err)
}
t.Logf("%q", body)
}
Run Code Online (Sandbox Code Playgroud)
而我正在提出这样的要求:
// Send HTTP Request, return data
func (f *firebaseRoot) SendRequest(method string, path string, body io.Reader) ([]byte, error) {
url := f.BuildURL(path)
// create a …
Run Code Online (Sandbox Code Playgroud) go ×1