A request target bundles the path and an optional query string behind a question mark. Today you separate the two, since routing cares about the path while handlers care about the query.
Split a request target at the first "?" into a path and a raw query string.
The request target is really two things glued together: the path that names a
resource and an optional query string carrying parameters. They are separated
by the first ?. Routing decisions look only at the path, so pulling the query
off keeps /search?q=cats from being treated as a different route than
/search.
Split at the first ? and keep everything after it as the raw query — you will
decode it into key/value pairs in a later lesson. A target with no ? has an
empty query, and the path is the whole target. Store both on the Request so
handlers can reach them.
if i := strings.IndexByte(target, '?'); i >= 0 {path, rawQuery = target[:i], target[i+1:]} else {path, rawQuery = target, ""}