go.rice
go.rice copied to clipboard
rice 2.0: move away from source parsing and use a Ricefile?
"Rice 2.0? But 1.0 hasn't even been released yet!?" Correct. Please see #48 about that.
Dropping .go file source parsing I've been thinking about this for a while now. The parsing of go source is a nice feature, but doesn't always work as expected:
const boxName = `someBox`
rice.FindBox(boxName) // will work in 'live' mode, but rice tool won't find this box so it isn't embedded/appended.
This can be solved by moving the configuration of boxes to a Ricefile; a config file in some human-readable format such as yaml. This also allows us to define more configuration parameters per box such as:
- strategy: embed vs append (embed one box, append the other).
- path different than box name
Ricefile should be located in main package for the binary, but can include boxes used in sub-packages. Ricefile import other Ricefiles based on import path? This could make defining resources in packages a feasible reality.
This issue is a work in progress..
The current rice tool cannot use build tags, another reason to move away from source analysis and towards a configuration file for boxes.
Appears the current rice tool fails when multiple packages live in the same directory too.
multiple packages in the same directory? That should never happen right? (maybe exceptionally when one package has -buildflag
and the other has +buildflag
). @burdges
Appears not. At least, it does not happen where I once thought I'd seen it happen, thanks!
There's another reason to do this - FindBox calls in global scope will work until the user uses embed-go, at which point it will fail, since variables are initialized before the init() functions are called. This has already confused people, as in issue #67.
I just needed to implement the ability for rice to append boxes without access to source files. Only just noticed this issue after I've finished, sorry about that. I've implemented slightly differently ..
If you're in a directory that has only the box contents but no source, you can run this:
rice appendbox --exec <executable> -b <box1> [ -b <box2> ]
See https://github.com/boyvinall/go.rice/commit/appendbox
@boyvinall I also came across this issue after having problems with source parsing. I implemented it similarly on the command line here - https://github.com/JonathanTech/go.rice/pull/1 . I added it as a separate command instead.
rice append-simple -b <box1> [-b <box2>] --exec <executable>