-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
embed: Files starting with - (dash) are not embedded (undocumented behavior) #45447
Comments
This seems like a bug. Files with names starting with |
Change https://golang.org/cl/311529 mentions this issue: |
Change https://golang.org/cl/316629 mentions this issue: |
For golang/go#45447 Change-Id: I38b13bc912851aa9b6cdeb851330a5ed97b743ac Reviewed-on: https://go-review.googlesource.com/c/mod/+/316629 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Change https://golang.org/cl/316789 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?amd64, linux
go env
OutputWhat did you do?
./files
and./files/subdir
./files/file
,./files/-file
./main.go
go run .
What did you expect to see?
What did you see instead?
Analysis
This behavior was introduced with commit 930c2c9 where
isBadEmbedName
has been extended withif err := module.CheckFilePath(name); err != nil {
.The thing with
module.CheckFilePath
is, that it expects a full path as argument. For such a path, the first segment is not allowed to start with a-
(dash) according to https://github.com/golang/mod/blob/d6ab96f2441f9631f81862375ef66782fc4a9c12/module/module.go#L374.In the case of
isBadEmbedName
, the functionmodule.CheckFilePath
is called with the filename only (without the rest of the path), which prevents any file, starting with-
to be embedded.This behavior is nowhere documented. The current documentation only mentions, that files starting with
.
and_
are ignored.Additionally, nor the documentation of
module.CheckFilePath
neither ofmodule.CheckImportPath
do mention, that paths starting with-
are not allowed.Related: #45197, #43854, #44486
Update: add #44486 as related issue
The text was updated successfully, but these errors were encountered: