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
This behavior was introduced with commit 930c2c9 where isBadEmbedName has been extended with if 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 function module.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 of module.CheckImportPath do mention, that paths starting with - are not allowed.
This seems like a bug. Files with names starting with - in the module root directory should not be embeddable, but files in other directories should be embeddable.
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>
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: