mirror of
https://github.com/Jguer/yay
synced 2024-10-06 16:19:12 +00:00
8916cd174b
* rework relationship between runtime and cfg * separate runtime from cfg * simplify instantiation logic * move installer to appropriate package * move operator to sync package * add tests for srcinfo service * consolidate srcinfo service in sync * add logger to srcinfo * add logger to preparer * remove unused text functions * remove remaining text.* from srcinfo * remove global logger parts * remove global org method exports * remove global logger * move text->input * add rule to prevent fmt.Print * update golangci go version * remove outdated FAQs * remove outdated FAQs
50 lines
860 B
Go
50 lines
860 B
Go
package text
|
|
|
|
import (
|
|
"strings"
|
|
"unicode"
|
|
)
|
|
|
|
const (
|
|
yDefault = "y"
|
|
nDefault = "n"
|
|
)
|
|
|
|
// SplitDBFromName split apart db/package to db and package.
|
|
func SplitDBFromName(pkg string) (db, name string) {
|
|
split := strings.SplitN(pkg, "/", 2)
|
|
|
|
if len(split) == 2 {
|
|
return split[0], split[1]
|
|
}
|
|
|
|
return "", split[0]
|
|
}
|
|
|
|
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
|
func LessRunes(iRunes, jRunes []rune) bool {
|
|
max := len(iRunes)
|
|
if max > len(jRunes) {
|
|
max = len(jRunes)
|
|
}
|
|
|
|
for idx := 0; idx < max; idx++ {
|
|
ir := iRunes[idx]
|
|
jr := jRunes[idx]
|
|
|
|
lir := unicode.ToLower(ir)
|
|
ljr := unicode.ToLower(jr)
|
|
|
|
if lir != ljr {
|
|
return lir < ljr
|
|
}
|
|
|
|
// the lowercase runes are the same, so compare the original
|
|
if ir != jr {
|
|
return ir < jr
|
|
}
|
|
}
|
|
|
|
return len(iRunes) < len(jRunes)
|
|
}
|