mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 13:18:43 -07:00
apt: VersionQuerier, Holder, Cleaner, FileOwner, RepoManager, KeyManager, NameNormalizer dpkg: FileOwner, NameNormalizer All new interfaces follow the existing pattern of exported methods on struct delegating to unexported platform-specific functions. Mutating operations use Lock/Unlock; read-only operations do not. Platform stubs in _other.go files return ErrUnsupportedPlatform. Compile-time interface checks added for all implemented interfaces.
22 lines
432 B
Go
22 lines
432 B
Go
package apt
|
|
|
|
import "strings"
|
|
|
|
func normalizeName(name string) string {
|
|
n, _ := parseArch(name)
|
|
return n
|
|
}
|
|
|
|
func parseArch(name string) (string, string) {
|
|
if idx := strings.LastIndex(name, ":"); idx >= 0 {
|
|
pkg := name[:idx]
|
|
arch := name[idx+1:]
|
|
switch arch {
|
|
case "amd64", "i386", "arm64", "armhf", "armel", "mips", "mipsel",
|
|
"mips64el", "ppc64el", "s390x", "all", "any":
|
|
return pkg, arch
|
|
}
|
|
}
|
|
return name, ""
|
|
}
|