-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package appimg | ||
|
||
type appimg struct { | ||
name string | ||
full string | ||
name string | ||
version string | ||
} | ||
|
||
func newApp(name string) appimg { | ||
var out appimg | ||
out.name = name | ||
out.full = name | ||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package appimg | ||
|
||
import "strings" | ||
|
||
func removeLetters(vers string) string { | ||
vers = strings.ToLower(vers) | ||
letters := []string{"abcdefghijklmnopqrstuvwxyz"} | ||
for _, v := range letters { | ||
vers = strings.Replace(vers, v, "", -1) | ||
} | ||
return vers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package appimg | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func compareVersions(imgs []appimg) int { | ||
for i := range imgs { | ||
imgs[i].version = removeLetters(imgs[i].version) | ||
} | ||
highest := 0 | ||
higharr := strings.Split(imgs[0].version, ".") | ||
for i := 0; i < len(imgs); i++ { | ||
if i != highest { | ||
varr := strings.Split(imgs[i].version, ".") | ||
if len(higharr) < len(varr) { | ||
for j := 0; j < len(higharr); j++ { | ||
h, _ := strconv.Atoi(higharr[j]) | ||
c, _ := strconv.Atoi(varr[j]) | ||
if h > c { | ||
break | ||
} else if c > h { | ||
highest = i | ||
higharr = varr | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return highest | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters