Skip to content

net/http: Redirect documentation refers to non-existent url identifier (it was renamed) #21077

@dmitshur

Description

@dmitshur

A very cool new package url was recently added to the Go standard library, see commit 1d8f822. To avoid a name collision, the existing url parameter of http.Redirect function was renamed to urlStr.

 // Redirect replies to the request with a redirect to url,
 // which may be a path relative to the request path.
-func Redirect(w ResponseWriter, r *Request, url string, code int) {
+func Redirect(w ResponseWriter, r *Request, urlStr string, code int) {

However, it looks like you forgot to update the documentation accordingly. It should be changed as follows:

-// Redirect replies to the request with a redirect to url,
+// Redirect replies to the request with a redirect to urlStr,
 // which may be a path relative to the request path.

Otherwise, it's not clear which url is being referred to. One may inadvertently misinterpret it to mean r.URL, which is not the case.

(I was going through my open tabs, and noticed I forgot to hit submit on this one. Better late than never. 🤷‍♂️)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions