You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
proposal: enhance import directive to allow for alternatives on failure to better support promotion of experimental packages into the standard library
#22358
Closed
jeking3 opened this issue
Oct 20, 2017
· 3 comments
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.
The Apache Thrift project detects the go version at build time and inserts different files into the build to support <1.6 or >1.7 based solely on this package and imports "the right one".
There are many other examples of this.
The text was updated successfully, but these errors were encountered:
ALTree
changed the title
Enhance import directive to allow for alternatives on failure to better support promotion of experimental packages into the standard library
proposal: enhance import directive to allow for alternatives on failure to better support promotion of experimental packages into the standard library
Oct 20, 2017
I've tagged this proposal but you'll definitely need to clarify the exact semantic of the change you are proposing to make this report a serious language change proposal.
Also, please note that Go tools almost never emit warnings, so I'm not convinced that the silently modifier will be well received.
Since the concern is mainly for packages brought into the standard library, I think you need to explain why build tags are insufficient.
For example, for the context package, as long as you want to support versions of Go before 1.7, import "golang.org/x/net/context". That package is written to use build tags to make the right thing happen: if using Go 1.7 or later, you will in effect get the standard library "context" package.
dsnet
added
the
v2
A language change or incompatible library change
label
Nov 10, 2017
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: