An interesting option that I've not seen proposed yet would be to accept go:embed comments before importing a package (obviating the need to write the assets package in my previous example).
So, assuming your assets are in the repository github.com/me/myproject/assets, you could just do:
And the go tool would take charge of generating an assets package with assets.Files.
Then we don't even need a magic embed package at all. And generating a package would give us more flexibility, for example:
package foo // import "foo.io/foo"
//go:embed Name string "name.txt"
//go:embed Data []byte "bin.dat"
//go:embed "images" "templates" "html/index.html"
import embedded "foo.io/foo"
//use embedded.Name, with type string
//use embedded.Data, with type []byte
//use embedded.Files, with type fs.FS
I was kind of hoping for:
But one issue with this is that it might make a dogs breakfast of the filenames within the `assets` object -- it sort of needs something like this: (and it would not include the $ASSETS path in the object).