-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: embed: give error in 1.14.x and 1.15.x if a go:embed directive is seen #43558
Comments
I've been, based on this case, wondering whether that should apply to any unrecognized |
My first thought is that we don't want to do this for any unrecognized "go:" directive. For example, ignoring "go:noinline", seems unlikely to cause real harm. It's only important to give an error for directives for which ignoring the directive causes the program behavior to break. |
I think the tradeoff is, that with a rejection-list, people will still need to keep up with the latest point-release to prevent themselves from running into this problem. i.e. people who don't upgrade to go1.15.7 (or whatever would be the specific version) will still have this problem. That might be fine. As usual, I'm very fine letting other people make this tradeoff, I don't have super strong opinions :) |
Wasn’t part of the intent of making //go: directives comments that they’re not a part of the language, don’t have to be supported by other tool chains, and so shouldn’t be considered breaking if they’re ignored? I think pragmatically this is a good change, but is it violating the meaning of //go:? |
Users will run into plenty of problems if they don't stay up to date with stable releases. I personally think that's fine. |
@hherman1 I think it's a bit more nuanced than that. An example is formatting tools like gofmt and goimports; if the Go language is extended, they'd have to be updated to keep working normally. Whereas normal comment directives are just comments. Other tool chains or implementations of Go can choose what to do with #43217 could do a better job at this, I think. If an external Go implementation does not support the |
I think this is a superficial workaround for a much deeper design issue in #43217 and #41191. Backporting a compile error to 1.14 and 1.15 does not help users who are still on 1.13 (even though it is unsupported at this point), or who are using one of the myriad alternate Go implementations (such as It's better than nothing, but I would prefer that we instead defined |
I don't strongly object to your suggestion, but I also don't think we should optimize for the transition period. This proposal is an aid to the transition, it's not essential. |
The most we should do in a Go 1.14.x and 1.15.x point release would be to reject //go:embed. We certainly should not reject all other unrecognized //go comments in a point release. I'm pretty sure we shouldn't do it at all, but if we were going to, that's the kind of exciting (might break your code) change you'd do in a new major release. Point releases must not be that kind of exciting. |
An example of why we would not want to reject all unknown //go: comments is the |
@rsc Yeah, sorry, I didn't actually wanted to suggest to do that in a point-release anyway, I meant more medium-term :) And if you don't think it's a good idea, that's fine. |
No worries, I just wanted to make sure the discussion for the point release was narrowly scoped. |
As we are now likely to decline #43217, I'm retracting this proposal. |
This is an idea from @marwan-at-work described at #43217 (comment).
We seem likely to accept proposal #43217 which will permit writing code like
In particular this file will not need to import the "embed" package. It follows that this code will compile without errors when using a release of Go from before 1.16, but the code will not work as expected.
To reduce the possibility of problems during this transition, this proposal is that for the next Go 1.14.x and 1.15.x releases, any line comment at package scope that starts with
//go:embed
should be treated as a compilation error.CC @Merovius @rsc @robpike
The text was updated successfully, but these errors were encountered: