sort.Stable(ms)
}
-var DefaultMenuEntrySort = func(m1, m2 *MenuEntry) bool {
+var defaultMenuEntrySort = func(m1, m2 *MenuEntry) bool {
if m1.Weight == m2.Weight {
return m1.Name < m2.Name
- } else {
- return m1.Weight < m2.Weight
}
+ return m1.Weight < m2.Weight
}
func (ms *MenuSorter) Len() int { return len(ms.menu) }
// Less is part of sort.Interface. It is implemented by calling the "by" closure in the sorter.
func (ms *MenuSorter) Less(i, j int) bool { return ms.by(ms.menu[i], ms.menu[j]) }
-func (p Menu) Sort() {
- MenuEntryBy(DefaultMenuEntrySort).Sort(p)
+func (m Menu) Sort() {
+ MenuEntryBy(defaultMenuEntrySort).Sort(m)
}
-func (p Menu) Limit(n int) Menu {
- if len(p) < n {
- return p[0:n]
- } else {
- return p
+func (m Menu) Limit(n int) Menu {
+ if len(m) < n {
+ return m[0:n]
}
+ return m
}
-func (p Menu) ByWeight() Menu {
- MenuEntryBy(DefaultMenuEntrySort).Sort(p)
- return p
+func (m Menu) ByWeight() Menu {
+ MenuEntryBy(defaultMenuEntrySort).Sort(m)
+ return m
}
-func (p Menu) ByName() Menu {
+func (m Menu) ByName() Menu {
title := func(m1, m2 *MenuEntry) bool {
return m1.Name < m2.Name
}
- MenuEntryBy(title).Sort(p)
- return p
+ MenuEntryBy(title).Sort(m)
+ return m
}
func (m Menu) Reverse() Menu {
}
func (ts testMenuState) findTestMenuEntry(mn string, id string, matcher func(me *MenuEntry, id string) bool) *MenuEntry {
- var found *MenuEntry = nil
+ var found *MenuEntry
if menu, ok := ts.site.Menus[mn]; ok {
for _, me := range *menu {
}
func (ts testMenuState) findDescendantTestMenuEntry(parent *MenuEntry, id string, matcher func(me *MenuEntry, id string) bool) *MenuEntry {
- var found *MenuEntry = nil
+ var found *MenuEntry
if parent.HasChildren() {
for _, child := range parent.Children {
}
func tomlToMap(s string) (map[string]interface{}, error) {
- var data map[string]interface{} = make(map[string]interface{})
+ var data = make(map[string]interface{})
if _, err := toml.Decode(s, &data); err != nil {
return nil, err
}