1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
| package download
import ( "github.com/samber/lo" )
type Link struct { URL string `json:"url"` Mode string `json:"mode"` OS string `json:"os"` Arch string `json:"arch"` }
func (l *Link) ArchString() string { switch l.Arch { case ArchAMD64: return "Intel 64-bit" case ArchARM64: return "ARM64" case ArchARMV5: return "ARM v5" case ArchARMV6: return "ARM v6" case ArchARMV7: return "ARM v7" case Arch386: return "Intel 32-bit" case ArchMIPS64Hard: return "MIPS64 (hardfloat)" case ArchMIPS64LEHard: return "MIPS64 (le, hardfloat)" case ArchMIPS64LESoft: return "MIPS64 (le, softfloat)" case ArchMIPS64Soft: return "MIPS64 (softfloat)" case ArchMIPSHard: return "MIPS (hardfloat)" case ArchMIPSLEHard: return "MIPS (le, hardfloat)" case ArchMIPSLESoft: return "MIPS (le, softfloat)" case ArchMIPSSoft: return "MIPS (softfloat)" case ArchLoong64: return "Loong64" case ArchPPC64: return "PPC64" case ArchPPC64LE: return "PPC64 (le)" case ArchRISCV64: return "RISC-V 64-bit" case ArchS390X: return "S390x" case ArchUniversal: return "All (Universal)" case ArchWASM: return "WASM" case "apk", "app": return "Application" case "aar": return "AAR Library" case "framework": return "Xcode Framework" default: return l.Arch } }
func (l *Link) OSString() string { switch l.OS { case OSAIX: return "AIX" case OSAndroid: return "Android" case OSDragonfly: return "Dragonfly" case OSFreeBSD: return "FreeBSD" case OSIllumos: return "Illumos" case OSIOS: return "iOS" case OSJS: return "JavaScript" case OSLinux: return "Linux" case OSMac: return "macOS" case OSNetBSD: return "NetBSD" case OSOpenBSD: return "OpenBSD" case OSPlan9: return "Plan9" case OSSolaris: return "Solaris" case OSWindows: return "Windows" } return "Unknown" }
func (l *Link) OSIcon() string { switch l.OS { case OSAndroid: return OSAndroid case OSLinux: return OSLinux case OSMac, OSIOS: return "apple" case OSWindows: return OSWindows default: return "star" } }
type Links []*Link
func (l Links) Get(mode string, os string, arch string) *Link { return lo.FindOrElse(l, nil, func(link *Link) bool { return link.Mode == mode && link.OS == os && link.Arch == arch }) }
func (l Links) GetByModes(modes ...string) Links { return lo.Filter(l, func(link *Link, _ int) bool { return lo.Contains(modes, link.Mode) }) }
func (l Links) GetByOS(os string) Links { return lo.Filter(l, func(link *Link, _ int) bool { return link.OS == os }) }
var availableLinks Links
const ( ModeServer = "server" ModeDesktop = "desktop" ModeMobile = "mobile"
OSAIX = "aix" OSAndroid = "android" OSDragonfly = "dragonfly" OSFreeBSD = "freebsd" OSIllumos = "illumos" OSIOS = "ios" OSJS = "js" OSLinux = "linux" OSMac = "darwin" OSNetBSD = "netbsd" OSOpenBSD = "openbsd" OSPlan9 = "plan9" OSSolaris = "solaris" OSWindows = "windows"
ArchAMD64 = "amd64" ArchARM64 = "arm64" ArchARMV5 = "armv5" ArchARMV6 = "armv6" ArchARMV7 = "armv7" Arch386 = "386" ArchMIPS64Hard = "mips64_hardfloat" ArchMIPS64LEHard = "mips64le_hardfloat" ArchMIPS64LESoft = "mips64le_softfloat" ArchMIPS64Soft = "mips64_softfloat" ArchMIPSHard = "mips_hardfloat" ArchMIPSLEHard = "mipsle_hardfloat" ArchMIPSLESoft = "mipsle_softfloat" ArchMIPSSoft = "mips_softfloat" ArchLoong64 = "loong64" ArchPPC64 = "ppc64" ArchPPC64LE = "ppc64le" ArchRISCV64 = "riscv64" ArchS390X = "s390x" ArchUniversal = "all" ArchWASM = "wasm" )
|