Golang HTTP请求POST一次

I have a master and slave. Master have api call result, which takes JSON. And i have proplem with slave, which send this result on master, the first time my code sends json well, but second time, code stop(program wait.....) on resp, err := client.Do(req), when create query on master. salve code:

func main (){
    for {
        // some code, very long code
        sendResult(resFiles)
    }
}

func sendResult(rf common.ResultFiles) {
    jsonValue, err := json.Marshal(rf)
    req, err := http.NewRequest(methodPost, ResultAdress, 
                                bytes.NewBuffer(jsonValue))
    req.Header.Set("Content-Type", ContentType)
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    fmt.Println("response Status:", resp.Status)
}

master api call:

func result(c echo.Context) error {
    rf := &ResultFiles{}
    err := c.Bind(rf)
    if err != nil {
        log.Fatal(err)
    }
    rfChannel <- *rf
    return c.JSON(http.StatusOK, nil)
}

My question: Why? May be problem in the standard client golang (http.Client) or timeout? If i set timout - my code crashed by timeout)))anticipated.... Thank you!

You need to add a timeout to your http.Client. By default http.Client has timeout specified as 0 which means no timeout at all. So if server is not responding than your application will just hang waiting for a response. This problem is fully described in this article Don’t use Go’s default HTTP client (in production). Though you create custom client you still need to specify timeout.

Problem link with channel, i send result work slave on master to channel, but channel work without loop, i add loop for read data from channel and all work.