Open FlorentinDUBOIS opened 6 years ago
I like it. I’m wondering is it worth making NewBox accept N number of folders? Or do with this approach? In either case what’s the order of file lookup? FIFO? Or LIFO? Of dist and public both contain foo.txt which one is served up?
According to me, a box is associated to a specific folder. So, with this approach an array of box are corresponding to the same number of folders.
In addition, I found easier to maintain a type Boxes
which an alias of Box
because it benefit of all box methods and interfaces implementations.
For me, the order is the one given in parameters of the NewBoxes
method. So, a method like MustBytes
may have an implementation pretty simple which are easy to maintain, like this:
// MustBytes return the bytes representation of the asset or an error
func (b Boxes) MustBytes(name string) ([]byte, error) {
for _, box := range b {
if !box.Has(name) {
continue
}
return box.MustBytes(name)
}
return nil, fmt.Errorf("No asset found for: %s", name)
}
With this way to manage box, if some boxes contains the same file name, it is the box which is declare in first position that will be used.
This is my way to manage boxes. What do you thinks about it ? Do you agree ? Have you some points you thinks that it will be difficult to implements ?
Hello!
I have a case where I have to wrap packr into an array of Box in order to preserve semantic. So, I wonder if it is a good idea to provide a type alias which is an array of box.
This type will implement all methods that a box implements. An example of the usage may be:
What do you thinks about this feature ?