Debian Codegraph @

README.md

raw
1 # go-bindata-assetfs
2
3 Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) with `net/http`.
4
5 [GoDoc](http://godoc.org/github.com/elazarl/go-bindata-assetfs)
6
7 ### Installation
8
9 Install with
10
11 $ go get github.com/jteeuwen/go-bindata/...
12 $ go get github.com/elazarl/go-bindata-assetfs/...
13
14 ### Creating embedded data
15
16 Usage is identical to [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) usage,
17 instead of running `go-bindata` run `go-bindata-assetfs`.
18
19 The tool will create a `bindata_assetfs.go` file, which contains the embedded data.
20
21 A typical use case is
22
23 $ go-bindata-assetfs data/...
24
25 ### Using assetFS in your code
26
27 The generated file provides an `assetFS()` function that returns a `http.Filesystem`
28 wrapping the embedded files. What you usually want to do is:
29
30 http.Handle("/", http.FileServer(assetFS()))
31
32 This would run an HTTP server serving the embedded files.
33
34 ## Without running binary tool
35
36 You can always just run the `go-bindata` tool, and then
37
38 use
39
40 import "github.com/elazarl/go-bindata-assetfs"
41 ...
42 http.Handle("/",
43 http.FileServer(
44 &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"}))
45
46 to serve files embedded from the `data` directory.