This code compiles fine:
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
", r.URL.Path)
h.ServeHTTP(w, r)
}
but if I add a new-line after the last paren in the fmt.Println call:
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
", r.URL.Path)
h.ServeHTTP(w, r)
}
now it won't compile, what's the reason for this? I added a comment next to difference in the second code sample, also just writing more b/c it said my question had too much code and not enough words thanks.