Every header is a name and a value separated by a colon. Today you split one header line into its two parts, trimming the optional whitespace HTTP allows after the colon.
Split a header line into a name and a value at the first colon, trimming surrounding whitespace from the value.
A header field is Name: Value. The split happens at the first colon,
because values are free to contain colons of their own — timestamps, URLs, and
IPv6 addresses all do. Slicing at the first colon and keeping the rest verbatim
avoids mangling them.
HTTP permits optional whitespace around a header value (it is called OWS in the spec), so trim spaces off the value. Leave the name exactly as written for now — the next lesson handles the fact that names are matched case-insensitively.
i := strings.IndexByte(line, ':') // FIRST colon onlyif i < 0 {return "", "", errors.New("bad header")}name := line[:i]value := strings.TrimSpace(line[i+1:])