forked from coop-cloud/abra
refactor: reverse list function finally
This commit is contained in:
parent
bac6fb0fa8
commit
43e68a99b0
@ -183,9 +183,7 @@ can take some time.
|
||||
stats.latestCount++
|
||||
}
|
||||
} else {
|
||||
for i, j := 0, len(newUpdates)-1; i < j; i, j = i+1, j-1 {
|
||||
newUpdates[i], newUpdates[j] = newUpdates[j], newUpdates[i]
|
||||
}
|
||||
newUpdates = internal.ReverseStringList(newUpdates)
|
||||
appStats.upgrade = strings.Join(newUpdates, "\n")
|
||||
stats.upgradeCount++
|
||||
}
|
||||
|
@ -112,9 +112,7 @@ recipes.
|
||||
}
|
||||
}
|
||||
|
||||
for i, j := 0, len(availableDowngrades)-1; i < j; i, j = i+1, j-1 {
|
||||
availableDowngrades[i], availableDowngrades[j] = availableDowngrades[j], availableDowngrades[i]
|
||||
}
|
||||
availableDowngrades = internal.ReverseStringList(availableDowngrades)
|
||||
|
||||
var chosenDowngrade string
|
||||
if !internal.Chaos {
|
||||
|
@ -119,6 +119,8 @@ recipes.
|
||||
}
|
||||
}
|
||||
|
||||
availableUpgrades = internal.ReverseStringList(availableUpgrades)
|
||||
|
||||
var chosenUpgrade string
|
||||
if len(availableUpgrades) > 0 && !internal.Chaos {
|
||||
if internal.Force {
|
||||
|
10
cli/internal/list.go
Normal file
10
cli/internal/list.go
Normal file
@ -0,0 +1,10 @@
|
||||
package internal
|
||||
|
||||
// ReverseStringList reverses a list of a strings. Roll on Go generics.
|
||||
func ReverseStringList(strings []string) []string {
|
||||
for i, j := 0, len(strings)-1; i < j; i, j = i+1, j-1 {
|
||||
strings[i], strings[j] = strings[j], strings[i]
|
||||
}
|
||||
|
||||
return strings
|
||||
}
|
Loading…
Reference in New Issue
Block a user