-
Notifications
You must be signed in to change notification settings - Fork 18.1k
proposal: embed: treat /
as module's root in go:embed
directive
#58525
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
Comments
This comment was marked as spam.
This comment was marked as spam.
what would this resolve to in non module mode? |
thre would be two options imao:
|
In general source files are not supposed to depend on where module boundaries are. We want to be able to split a module into two modules without having to go edit every single file in the module. The special meaning for "/" would break that property. It also complicates interpretation by other tools. It would also introduce ambiguity in that //go:build /foo foo would have two different foo being embedded, both laying claim to data.Open("foo"). The current limitation of embedded files being required to be in the current package directory or a subdirectory seems acceptable given the complexities we'd be introducing to try to remove it. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
Consider the following code:
Since fs.ValidPath, sadly
Open
will not be able to handle this/
at the beginning, but it could be treated as module's root (in go:embed directive) and than removed fromembed.FS
.//go:embed <path to file in parent directory>
doesn't work #46056The text was updated successfully, but these errors were encountered: