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: api: add mechanism for correlating deprecations with Go versions e.g. <version_deprecated>.txt #38149

Closed
odeke-em opened this issue Mar 29, 2020 · 8 comments

Comments

@odeke-em
Copy link
Member

Just coming here from #37650 in which a user was mistakenly using a long deprecated field net/http/httptest.Recorder.HeaderMap instead of net/http/httptest.Recorder.Result()
Screen Shot 2020-03-28 at 11 42 07 PM

While we use the // Deprecated: notice as the de facto standard for deprecating fields, it might be very useful for one to know when a field was deprecated.

I propose that just like we have api/<version>.txt whose entries are of the form:
pkg <PKG_NAME>, <IDENTIFIER>
that we add another form also within that same directory <api/version_deprecated>.txt, whose line content formats will be the exact same as those for api/<version>.txt, so no change in parser, but an addition would be that GoDoc can then quickly look up what was deprecated and when and render that along.

This way we can make for more powerful tooling like, for example pkg.go.dev could give a deprecation policy notice between versions and is even more advantageous:

  • if an organization follows a deprecation policy e.g. 6 months, or 2 Go-releases deprecation policy, we can then have a column that shows when code was deprecated and when code needs to be changed
  • when cutting releases, we can produce a list of deprecated content

Many Go deprecation notices are loosely followed because for the longest time we didn't have modules so years later, users would still using deprecated fields. This suggestion could help in issuing stale code notices and not just when they switch to a module and have to suddenly re-write their code. This can help with more powerful refactoring.

@bcmills
Copy link
Contributor

bcmills commented Mar 30, 2020

CC @julieqiu @jba (since this could also be surfaced in pkg.go.dev)

@jba
Copy link
Contributor

jba commented Mar 30, 2020

I don't think pkg.go.dev would need that file. It could just figure it out while it "ingests" a new go version, from that version's godoc plus the data from the previous version.

@rsc rsc added this to Incoming in Proposals (old) Apr 15, 2020
@rsc
Copy link
Contributor

rsc commented Apr 15, 2020

This file seems like an index that can be mechanically derived, not something we should require committing and letting drift out of date. pkg.go.dev can handle the main Go repo just fine, and I wouldn't want to impose new restrictions on other module maintainers for things that we can determine automatically.

@rsc rsc moved this from Incoming to Active in Proposals (old) Apr 15, 2020
@kaey
Copy link

kaey commented Apr 16, 2020

staticcheck already flags usage of deprecated symbols
https://staticcheck.io/docs/checks#SA1019

@rsc
Copy link
Contributor

rsc commented Apr 22, 2020

Based on the discussion above, this sounds like a likely decline (better to do automatically instead of a separate file that must be kept up to date).

@rsc rsc moved this from Active to Likely Decline in Proposals (old) Apr 22, 2020
@rsc
Copy link
Contributor

rsc commented Apr 29, 2020

No change in consensus. Declined.

@rsc rsc moved this from Likely Decline to Declined in Proposals (old) Apr 29, 2020
@odeke-em
Copy link
Member Author

Given that there is a way for ingestion to happen, I am fine with the decline. Thank you for the discourse and analyses everyone.

@rsc
Copy link
Contributor

rsc commented Jun 10, 2020

Forgot to close.

@rsc rsc closed this as completed Jun 10, 2020
@golang golang locked and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

6 participants