Small Box is a small library to embed static content into Golang Binary.
By generating go files with it content.
The small box is not suitable to high performance and it will increase the size of binary compiled.
But there is situations when it is suitable to use like when:
-
Have a static content and as planning to add it into a variable with a huge content.
-
Prefer to have everything into the binary instead of download external content, or have install a lib folder somewhere.
$ smallbox -f ./foo/boo.tpl -n boo -p ./
Boxing: ./foo/boo.tpl boo
It will create a foler with this:
|-- box
| |-- box.go
| |-- boxed_box.go
| `-- boxed_boxed.go
Booxing a directory
$ sbmallfox -d ./fooboomafoo -n foo
Boxing: ./fooboomafoo/boo.tpl as foo/boo.tpl
Boxing: ./fooboomafoo/foo.tpl as foo/foo.tpl
...
Boxing: ./fooboomafoo/zoo.tpl as foo/zoo.tpl
Using the flag "--help" will show all commands possibilities and flags.
smallbox --help
See which version smallbox is:
smallbox --version
package main
import "WHERE_BOX_FOLDER_IS/box"
func main(){
// CONTENT_NAME is what is given with -n flag if -n is not used it will be the value of -f
bContent, err := box.Get("CONTENT_NAME")
if err != nil {
panic(err)
}
fmt.Println(string(bContent))
}
I test smallbox with monkey patch, but I will add an example in future about how test if with go-mock Issue #10.
But there is already an example of how test it on example folder.
Testing with Stub here.
If you are using Moneky Patch to make stubs it may be necessary add this into test command -gcflags="all=-N -l"
it will make the test binary not do any optimization on it, which is necessary to Monkey Patch works fine.
Please, opening a Issue be specific, give examples, which version smallbox is, and if possible an way to reproduce.
Open a issue https://github.com/roger-russel/smallbox/issues.
Some limitations found into this project.
Smallbox must use a folder called box, because it is how package works in Golang. If you are aready using folder with box name, then you must change the path to box folder like this:
$ smallbox -f ./foo/boo.tpl -n boo -p ./autogenerated
Boxing: ./foo/boo.tpl boo
It will create a foler with this:box
|-- autogenerated
| `-- box
| |-- box.go
| |-- box_test.go
| |-- boxed_box.go
| `-- boxed_boxed.go
|