Skip to content
/ bindata Public

Conver regular files into a single golang package

Notifications You must be signed in to change notification settings

wrfly/bindata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BinData

Although there are many golang programs who transfer files into go packages, such as jteeuwen/go-bindata, a-urth/go-bindata, and go-bindata-assetfs, but I still felt not good with them.

So I wrote one myself.

GoDoc

Install

Install the bindata cmd with:

go get github.com/wrfly/bindata

Usage

Usage of ./bindata:
 -dest        path to store go asset files, default is the pkg path
 -pkg         package name [github.com/wrfly/bindata/example/asset]
 -prefix      resource prefix, used for static files in HTTP server [/]
 -src         resource dir
 -with-mod    generate file with its mod info [false]
 -with-time   generate file with its time info [false]

Generate embedded data

For example, if you want to generate a asset package, who's path is github.com/wrfly/bindata/example/asset, the resource files are located in resource/ directory, then yoy can use the command below:

bindata -pkg github.com/wrfly/bindata/example/asset \
    -src "resource/"

After execute the command:

$ ls $GOPATH/src/github.com/wrfly/bindata/example/asset
asset.go  bindata.go

And now, you can use this asset package with:

package main

import (
    "net/http"

    "github.com/wrfly/bindata/example/asset"
)

func main() {
    http.HandleFunc("/", asset.Handler)
    http.ListenAndServe(":8080", nil)
}

Look at the example folder for more details and usage examples.

About

Conver regular files into a single golang package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages