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

proposal: x/net/context: deprecate package or symbols in package, and potentially tag/delete #49506

Open
frioux opened this issue Nov 10, 2021 · 5 comments
Labels
Milestone

Comments

@frioux
Copy link

frioux commented Nov 10, 2021

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

$ go version
go version go1.17.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/frew/.cache/go-build"
GOENV="/home/frew/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-mod=readonly"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/frew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/frew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org"
GOROOT="/home/frew/go/installations/go1.17.1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/frew/go/installations/go1.17.1/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/frew/code/zr0/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/run/shm/go-build2449590503=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Accidentally used golang.org/x/net/context

What did you expect to see?

A deprecation warning caught by our linter. Basically I think we should mark the package (or symbols in the package) deprecated so that linters would notice and automatically suggest people switch to context.

What did you see instead?

Nothing.

@gopherbot gopherbot added this to the Unreleased milestone Nov 10, 2021
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 12, 2021
@cagedmantis
Copy link
Contributor

/cc @neild @ianlancetaylor

@neild
Copy link
Contributor

neild commented Nov 12, 2021

The context package has been in the standard library for a long time. Deprecating x/net/context seems reasonable.

@dmitshur
Copy link
Contributor

There's also a context fix available to aid with the migration, so
go fix can be run to effortlessly migrate multiple packages:

$ go fix ./...
example/file.go: fixed context
anotherpackage/http.go: fixed context
[…]
$

Deprecations (and deletions) need an accepted proposal. We can repurpose this issue.

@dmitshur dmitshur changed the title x/net/context: deprecate package or symbols in package proposal: x/net/context: deprecate package or symbols in package, and potentially tag/delete Feb 16, 2025
@dmitshur dmitshur added Proposal and removed Proposal NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 16, 2025
@dmitshur dmitshur modified the milestones: Unreleased, Proposal Feb 16, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/650155 mentions this issue: context: delete dead code, sync docs with upstream context package

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/650156 mentions this issue: context: delete lone example

gopherbot pushed a commit to golang/net that referenced this issue Feb 18, 2025
The go directive is now at 1.23.0, so the go1.7 and go1.9 build
constraints are guaranteed to always be satisfied, and their inverse
will never be satisfied. Delete all the dead code and merge everything
that's left in a single context.go file. Also update docs to match the
upstream context package.

For golang/go#49506.

Change-Id: I317550767838a93af2c2d3dbc7b61f2e37e6fe1c
Reviewed-on: https://go-review.googlesource.com/c/net/+/650155
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
gopherbot pushed a commit to golang/net that referenced this issue Feb 18, 2025
This is motivated by a few reasons. One, the upstream package has more
examples, and no one should be looking at this old package to learn how
to use it. Seeing an example might make it seem like the scope of the
documentation here is to provide examples, and that there aren't many
of them. Instead of trying to add more examples or maintain the current
one by porting the de-flake enhancement from CL 460999, delete the only
example here.

Second, running 'go fix ./...' causes the 'context' fix to rewrite the
import path of the example from "golang.org/x/net/context" to "context".
That is a false positive in the fix, and I would've liked it fix the
fix, but it only has the AST information at this time, not type info,
so the import path isn't currently available to the check. That means
it can't know when it's running on the golang.org/x/net/context package,
which is the one place it should skip the rewrite.

It seems simpler to just delete the example, and then it becomes
possible to use 'go fix ./...' safely on the entire x/net module.

For golang/go#49506.

Change-Id: I97eba33ca2e1f2960aef8340d8b561639a26ee48
Reviewed-on: https://go-review.googlesource.com/c/net/+/650156
Reviewed-by: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
@ianlancetaylor ianlancetaylor moved this to Incoming in Proposals Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

5 participants