Skip to content

net/http: incorrect http.ResponseController usage example in Go 1.20 release notes #57162

Closed
@artyom

Description

@artyom

What version of Go are you using (go version)?

go version go1.20rc1 darwin/arm64

What did you do?

Pasted a HTTP ResponseController usage example from Go 1.20 release notes draft:

package pkg

import (
	"io"
	"net/http"
	"strings"
)

func RequestHandler(w http.ResponseWriter, r *http.Request) {
	rc := http.NewResponseController(w)
	rc.SetWriteDeadline(0) // disable Server.WriteTimeout when sending a large response
	io.Copy(w, strings.NewReader("hello"))
}

https://go.dev/play/p/F16HmEJ7NUU

What did you expect to see?

No build errors.

What did you see instead?

Incorrect http.ResponseController.SetWriteDeadline call — it's called with an int constant, when this method expects time.Time type.

¶ go vet
# pkg
vet: ./pkg.go:11:22: cannot use 0 (untyped int constant) as time.Time value in argument to rc.SetWriteDeadline

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions