Slices

When Go Slice Bounds Get Hazy

Earlier this week, I thought I stumbled across a bug in the go standard library. Earlier this week, I was wrong. While browsing the net/http sources, I spotted what appears to be an index out of range in calls to http.Request.BasicAuth(). Decoding func parseBasicAuth(): If the value string has prefix “Basic “ base64 decode the remainder of the string find the index of the first colon (:) in the decoded result return username and password as the substrings before and after the colon, respectively But wait - what if there’s nothing after the colon?