I am trying to use embed.FS to store photographs for a website. There are photographs with a colon in the filename (an RFC3339 formatted timestamp) which were not appearing on the site. The logs reported the following error:
failed to open: open static/media/1920/image_2020-10-07T12:36:46Z.jpg: file does not exist
On investigation, it appears that files with a colon in the filename are not included in an embed.FS. It appears that an error is generated at compilation if a filename with a colon exists in the embedded root directory, but not if the problematic filename is in a subdirectory. In the latter case, the file is simply not included in the embedded FS.
This came as a surprise to me, since (1) the limitation with colons is not listed in the embed package documentation, (2) fs.ValidPath is documented as follows:
// Paths containing other characters such as backslash and colon
// are accepted as valid, but those characters must never be
// interpreted by an FS implementation as path element separators.
To replicate, I set up a directory like the following: