/
masteries.go
32 lines (29 loc) · 945 Bytes
/
masteries.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package common
import "sort"
type ChampionMasteries struct {
From string `json:"from"`
Author string `json:"author"`
Locations []string `json:"locations"`
Offense []string `json:"offense"`
Defense []string `json:"defense"`
Support []string `json:"support"`
}
func (m *ChampionMasteries) Sanitize() error {
if m.Offense == nil {
m.Offense = make([]string, 0)
}
if m.Defense == nil {
m.Defense = make([]string, 0)
}
if m.Support == nil {
m.Support = make([]string, 0)
}
if m.Locations == nil {
m.Locations = make([]string, 0)
}
sort.SliceStable(m.Offense, func(i, j int) bool { return m.Offense[i] < m.Offense[j] })
sort.SliceStable(m.Defense, func(i, j int) bool { return m.Defense[i] < m.Defense[j] })
sort.SliceStable(m.Support, func(i, j int) bool { return m.Support[i] < m.Support[j] })
sort.SliceStable(m.Locations, func(i, j int) bool { return m.Locations[i] < m.Locations[j] })
return nil
}