library and cmd tool-set for managment assets like go-bindata or go-assets.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/goblet
generator
.gitignore
.travis.yml
LICENSE
README.md
errors.go
file.go
file_test.go
filesystem.go
filesystem_test.go
glide.lock
glide.yaml
go.mod

README.md

goblet

Build Status Coverage Status GoDoc Go Report Card

library and cmd tools set for managment assets like go-bindata or go-assets

install

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

How to use

Simply create asset from a directory

goblet /pass/to/your/assets

Create asset with go:generate comment

goblet -g /pass/to/your/assets

Name different package name and output different directory

goblet -p mypackage -o ./mypackage /pass/to/your/assets

Help Command

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

Examples

see example repo dir for full of codes.

http static file

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)