https://github.com/yankeguo-deprecated/binfs-alt
embedded filesystem for go binary
https://github.com/yankeguo-deprecated/binfs-alt
echo echo-middleware embedded embedded-files filesystem go golang golang-library
Last synced: 3 months ago
JSON representation
embedded filesystem for go binary
- Host: GitHub
- URL: https://github.com/yankeguo-deprecated/binfs-alt
- Owner: yankeguo-deprecated
- License: mit
- Created: 2019-07-05T08:53:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T08:40:04.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T15:10:02.693Z (11 months ago)
- Topics: echo, echo-middleware, embedded, embedded-files, filesystem, go, golang, golang-library
- Language: Go
- Size: 32.2 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# binfs
[](https://travis-ci.org/go-guoyk/binfs)
[](https://goreportcard.com/report/go.guoyk.net/binfs)
embedded filesystem for go binary
## Usage
### Get binfs
```bash
go get go.guoyk.net/binfs/cmd/binfs # the cli tool
go get go.guoyk.net/binfs # the runtime package
```### Generate
```bash
binfs -pkg binfs_test public view > binfs.gen.go
```This command read the content of directory `public` and `view`, output a `binfs.gen.go` file
**This command only accept directories**
The argument `pkg` specifies package name in `binfs.gen.go` file, default is `main`
## Retrive
As long as binfs.gen.go is compiled with your source code, you can extract file with
```go
binfs.Open("/public/robots.txt")
```You can also use `binfs.FileSystem()` or `binfs.Find("subdir").FileSystem()` to get a implementation of `http.FileSystem`
## Integrate with `Echo`
```go
import go.guoyk.net/binfs/binfsechoe := echo.New()
e.Use(binfsecho.Static("public"))
```## Credits
Guo Y.K., MIT License