cmd/go: directories named vendor
are ignored in //go:embed
#45744
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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
)?go env
OutputWhat did you do?
Used
//go:embed <dir>
to recursively embed static website assets into anembed.FS
variable, and then rango install <repo>
to install the binary into gobin.What did you expect to see?
All assets embedded into the
embed.FS
variable in the final binary in gobin.What did you see instead?
Only some assets were embedded in the
embed.FS
variable in the final binary in gobin.The problem comes from having folders named
vendor
within the directory that gets embedded.If you create a project that embeds a directory, for example
//go:embed static
, which includes some sub-directory namedvendor
, for examplestatic/vendor/style.css
, then the embed behaviour is different depending on how you install the project into gobin.If you have the entire project source locally and you run
go install
within the project then thevendor
directory is correctly included and embedded into the final binary.If you push the project to somewhere like GitHub and then try to install via
go install <repo>
orgo get <repo>
, then all files are correctly embedded according to the documentation except for the entirevendor
folder, which is ignored. You can work around this by settingGO111MODULE=auto
. If this is set then thevendor
directory is no longer ignored and is correctly embedded in the final binary.I believe this is just an unintended side-effect of
go get
/go install
and how they deal withvendor
ed dependencies. If it is actually intended then it at the very least needs to be documented and made consistent across the different methods of installation.The text was updated successfully, but these errors were encountered: