Description
Proposal Details
//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:
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:
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
}
...
}