proposal: enhance import directive to allow for alternatives on failure to better support promotion of experimental packages into the standard library #22358
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
This issue is a generic enhancement request for go.
Background
An experimental package called "golang.org/x/net/context" exists. This package was brought into the standard language in go 1.7 as "context". This is one example - it will happen again in the future many times over.
Problem
The import directive does not allow for alternatives or versioning to facilitate a smooth transition between experimental and official standard package status. While go is backwards compatible, this transition is not, and it has impacted many projects.
Proposal
Modify the import directive in the language to allow for a fallback position, for example:
The two packages in this case have compatible APIs and therefore this single line of code would have spared hundreds of projects from having to deal with the transition of the context package into official status. The silently keyword would omit any warnings; without the keyword a warning would be emitted when an alternative is loaded.
Proof of Problem
There are many other examples of this.
The text was updated successfully, but these errors were encountered: