by andix · 11mo ago · 0 comments
I've seen a Go project that was heavily using https://pkg.go.dev/embed for loading some template files, and got a bit jealous. Back in the days of .NET Framework it was common to compile file contents into resource files, but it was always quite cumbersome.
<EmbeddedResource Include="/path/to/file.txt" />
Then you can read that file from the assembly with: assembly.GetManifestResourceStream
I'm not sure what's awkward about that, but it's nothing new.Discoverability for this is in visual studio, if you go to file properties there's a drop-down where you choose between Content, EmbeddedResource, Ignore, etc.
That determines what happens in compile, whether it is copied to output directory, compiled into the binary, etc.
In modern code I don't see them that often anymore.