-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: cmd/go: structured deprecated block in go.mod #64869
Comments
Note this isn't backwards compatible with older versions of Go. version seems like redundant information, once deprecated there's generally no version that's supported, nor does it seem wise to reencode the version of the module itself in go.mod newpath seems very restrictive, deprecation may include painting users to various other modules tooling generally already alerts users when using deprecated modules, this does not appear to enable anything new. see also #32816 |
I'd like to provide some clarifications regarding the points raised:
I believe these features, with their specific purposes and flexibility, could significantly enhance the way deprecations are handled in the Go ecosystem. I'm open to further discussion and suggestions to refine these aspects of the proposal. |
CC @matloob |
I agree with @seankhliao. It doesn't seem like this adds enough over the current deprecation comment format to be worth adding new syntax to go.mod files.
If versions are introduced after a deprecation happens then I think that retractions are the right way to handle them. I'm not sure why new versions of a module would be tagged after deprecation for a reason other than to add retract directives.
Patching earlier versions of Go is not an option for new features like this. We support the most recently released version of go as well as the previous release but we only make minor releases for "security issues, serious problems with no workaround, and documentation fixes". (See https://go.dev/wiki/MinorReleases)
If the purpose is to print a message, isn't it enough to put the new module information in the deprecation message? How would the new module field be used other than to display a message? |
Proposal Details
Abstract
This proposal introduces a
deprecated {}
block within thego.mod
file of Go modules. Its goal is to provide a structured, automated, and backward-compatible way for module maintainers to communicate package deprecations, including details like the last usable version, the reason for deprecation, and an optional new import path for continued development.Rationale
The current Go module system offers deprecation notices through comments (
// Deprecated: ...
) and theretract {}
section ingo.mod
. However, these approaches have limitations in terms of visibility and automation. This proposal enhances this mechanism by introducing a dedicated, structured, and easily parseable method for declaring package deprecations.Comparison with Current Mechanism
// Deprecated: ...
,retract {}
)go.mod
.deprecated {}
)go.mod
for deprecation details.Proposed Syntax Enhancements
The
deprecated {}
block ingo.mod
could allow both detailed and shorthand declarations:Table of Fields
version
message
newpath
Shorthand Declaration Example
Detailed Declaration Example
Impact on Tooling
This feature can be integrated into tools like
go get
andgo list
, providing warnings or recommendations when using deprecated packages. IDE integrations could also leverage this feature to alert developers during coding.Addressing Potential Concerns
deprecated {}
block should be backward compatible, ignored by older Go versions.The text was updated successfully, but these errors were encountered: