An accessor generator for files embedded with go:embed.
- Install go-embedding-accessor.
- Run
go-embedding-accessor
command at your repository.
$ go-embedding-accessor --pkg PACKAGE_NAME --files 'assets/*.txt' --name asset
You can find asset_embedding.go
in your repository.
So, your Go program get {show,list,restore}-{name} options.
In the following, the option name generated when "asset" is specified as name is used.
list-asset
list your embedding files.
$ my-app --list-asset
assets/a.txt
assets/b.txt
show-asset
show embedding file.
$ my-app --show-asset assets/a.txt
Contents of a.txt
restore-assets
restore embedding files.
$ my-app --restore-asset
You also specify output path by --restore-path
option.
Generated code (asset_embedding.go
) doesn't depend on your code, only provides {show,list,restore}-asset options at init() function.
$ go install github.com/monochromegane/go-embedding-accessor/cmd/go-embedding-accessor@latest
- Fork it
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Run
gofmt -s
- Create new Pull Request