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
//go:embed x/* currently will not embed filenames in the x subdirectory with a ' single-quote character in their filename, such as
x/tom's favorite file.txt
Single quote is not such a rare character that I think it should be outright rejected by embed. It would be useful if go:embed * could include filenames with a single-quote character in their name.
The globbed filenames are rejected based on the isBadEmbedName in pkg.go:
The commit (930c2c9) that introduced the usage of module.CheckFilePath references CL https://go-review.googlesource.com/c/go/+/290709, which talks a lot about fs.ValidPath. It seems like module.CheckFilePath was used to avoid certain bad windows filenames (COM, PRN, ...), but module.CheckFilePath is fairly restrictive in that it accepts a restricted set of ascii characters:
This proposal could be resolved by adding single quote ' to that allowed variable, although that would impact other code that uses the golang.org/x/mod/module module. Perhaps a solution would be a combination of fs.ValidPath and something that checks the bad windows names?
func isBadEmbedName(name string) bool {
if !fs.ValidName(name) {
return true
}
if module.IsBadWindowsName(name) {
return true
}
...
}
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Proposal Details
//go:embed x/*
currently will not embed filenames in thex
subdirectory with a'
single-quote character in their filename, such asSingle quote is not such a rare character that I think it should be outright rejected by embed. It would be useful if
go:embed *
could include filenames with a single-quote character in their name.The globbed filenames are rejected based on the
isBadEmbedName
in pkg.go:go/src/cmd/go/internal/load/pkg.go
Line 2271 in e39e965
Where
module.CheckFilePath
checks for a number of restrictions on the given name:go/src/cmd/vendor/golang.org/x/mod/module/module.go
Line 495 in e39e965
The commit (930c2c9) that introduced the usage of module.CheckFilePath references CL https://go-review.googlesource.com/c/go/+/290709, which talks a lot about fs.ValidPath. It seems like module.CheckFilePath was used to avoid certain bad windows filenames (COM, PRN, ...), but module.CheckFilePath is fairly restrictive in that it accepts a restricted set of ascii characters:
go/src/cmd/vendor/golang.org/x/mod/module/module.go
Line 285 in e39e965
This proposal could be resolved by adding single quote
'
to thatallowed
variable, although that would impact other code that uses thegolang.org/x/mod/module
module. Perhaps a solution would be a combination of fs.ValidPath and something that checks the bad windows names?The text was updated successfully, but these errors were encountered: