Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
artyom opened this issue Dec 8, 2022 · 2 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@artyom
Copy link
Member

artyom commented Dec 8, 2022

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
@seankhliao
Copy link
Member

cc @neild

@seankhliao seankhliao added Documentation NeedsFix The path to resolution is known, but the work has not been done. labels Dec 8, 2022
@seankhliao seankhliao added this to the Go1.20 milestone Dec 8, 2022
AlexanderYastrebov added a commit to AlexanderYastrebov/go that referenced this issue Dec 17, 2022
@gopherbot
Copy link

Change https://go.dev/cl/458275 mentions this issue: doc/go1.20: fix http.ResponseController example

@golang golang locked and limited conversation to collaborators Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants