library and cmd tools set for managment assets like go-bindata or go-assets
To use asset builder, get all packages.
go get -u github.com/deadcheat/goblet/...
To only use generated file, get single package
go get -u github.com/deadcheat/goblet
goblet /pass/to/your/assets
goblet -g /pass/to/your/assets
goblet -p mypackage -o ./mypackage /pass/to/your/assets
On command-line, goblet acts as asset builder like as go-assets-builder or go-bindata
NAME:
goblet - make a binary contain some assets
USAGE:
goblet [global options] command [command options] [arguments...]
VERSION:
1.3.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--expression value, -e value Regular expressions you want files to contain
--generate, -g If set, generate go:generate line to outputfile
--ignore-dotfiles If set, ignore dotfiles(i.e. '.gitkeep')
--exclude-empty-dir If set, ignore dotfiles(i.e. '.gitkeep')
--name value, -n value Variable name for output assets (default: "Assets")
--out value, -o value Output file name, result will be displaed to standard-out when it's skipped
--package value, -p value Package name for output (default: "main")
--help, -h show help
--version, -v print the version
see example repo dir for full of codes.
Generated asset is generated as implementation of http.FileSystem
http.Handle("/", http.FileServer(assetsbin.Assets))
log.Println("start server localhost:3000")
if err := http.ListenAndServe(":3000", nil); err != nil {
log.Fatal(err)
}
Sometimes we changed root on http request from "/" such as "/statics/",
goblet.FileSystem has WithPrefix
func.
http.Handle("/static/", http.FileServer(assetsbin.Assets.WithPrefix("/static/")))
log.Println("start server localhost:3000")
if err := http.ListenAndServe(":3000", nil); err != nil {
log.Fatal(err)
}
reading config file with config library like github.com/spf13/viper
goblet.File has bytes.Reader, so you can use goblet.File directly
viper.SetConfigType("toml")
f, _ := configbin.Assets.File("/config/configfile.toml")
viper.ReadConfig(f)
var s Server
_ = viper.UnmarshalKey("server", &s)