Этот код прекрасно компилируется:
return func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("tc_req_body_type") != m["request_body"] {
fmt.Println(
strings.Join([]string{"types are different", " actual:",
r.Header.Get("tc_req_body_type"), "expected:", m["request_body"]}," "))
}
if r.Header.Get("tc_resp_body_type") != m["response_body"] {
fmt.Println(
strings.Join([]string{"types are different", " actual: ",
r.Header.Get("tc_req_body_type"), " expected: ", m["request_body"]}," "))
}
fmt.Printf("Req: %s\n", r.URL.Path)
h.ServeHTTP(w, r)
}
, но если я добавлю новую строку после последнего имени в вызове fmt.Println:
return func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("tc_req_body_type") != m["request_body"] {
fmt.Println(
strings.Join([]string{"types are different", " actual:",
r.Header.Get("tc_req_body_type"), "expected:", m["request_body"]}," ")
) // <<< here
}
if r.Header.Get("tc_resp_body_type") != m["response_body"] {
fmt.Println(
strings.Join([]string{"types are different", " actual: ",
r.Header.Get("tc_req_body_type"), " expected: ", m["request_body"]}," ")
) // <<< here
}
fmt.Printf("Req: %s\n", r.URL.Path)
h.ServeHTTP(w, r)
}
, теперь он не будеткомпилировать, в чем причина этого?Я добавил комментарий к разнице во втором примере кода, также просто написал больше б / к, он сказал, что в моем вопросе слишком много кода и недостаточно слов, спасибо.