d3aeb7375d
* Moved MainTests into a dedicated folder * Added sorter for templates (sorts structs to top) * Fixed all the broken tests * Tidied up output.go functions * Only creating one MainTest (main_test.go) per app run now * Split test imports up into normal test imports & main test imports
42 lines
669 B
Go
42 lines
669 B
Go
package cmds
|
|
|
|
import "strings"
|
|
|
|
func (i importList) Len() int {
|
|
return len(i)
|
|
}
|
|
|
|
func (i importList) Swap(k, j int) {
|
|
i[k], i[j] = i[j], i[k]
|
|
}
|
|
|
|
func (i importList) Less(k, j int) bool {
|
|
res := strings.Compare(strings.TrimLeft(i[k], "_ "), strings.TrimLeft(i[j], "_ "))
|
|
if res <= 0 {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (t templater) Len() int {
|
|
return len(t)
|
|
}
|
|
|
|
func (t templater) Swap(k, j int) {
|
|
t[k], t[j] = t[j], t[k]
|
|
}
|
|
|
|
func (t templater) Less(k, j int) bool {
|
|
// Make sure "struct" goes to the front
|
|
if t[k].Name() == "struct.tpl" {
|
|
return true
|
|
}
|
|
|
|
res := strings.Compare(t[k].Name(), t[j].Name())
|
|
if res <= 0 {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|