common/maps: Improve append in Scratch

This commit consolidates the reflective collections handling in `.Scratch` vs the `tpl` package so they use the same code paths.

This commit also adds support for a corner case where a typed slice is appended to a nil or empty `[]interface{}`.

Fixes #5275
This commit is contained in:
Bjørn Erik Pedersen
2018-10-08 10:25:15 +02:00
parent 8e825ddf5b
commit 31a8bb8c07
12 changed files with 391 additions and 192 deletions

View File

@@ -19,10 +19,3 @@ package collections
type Grouper interface {
Group(key interface{}, items interface{}) (interface{}, error)
}
// Slicer definse a very generic way to create a typed slice. This is used
// in collections.Slice template func to get types such as Pages, PageGroups etc.
// instead of the less useful []interface{}.
type Slicer interface {
Slice(items interface{}) (interface{}, error)
}