-
Notifications
You must be signed in to change notification settings - Fork 3
/
installer.go
44 lines (35 loc) · 922 Bytes
/
installer.go
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
package installer
import (
"sort"
)
type Installer interface {
// target == "" means latest
Install(path, name string, target string) (installed string, err error)
ListVersions(snapshot bool) (versions []string, err error)
}
var Installers = make(map[string]Installer, 10)
func Get(name string) (installer Installer, ok bool) {
installer, ok = Installers[name]
return
}
func GetInstallerNames() (installers []string) {
installers = make([]string, 0, len(Installers))
for name, _ := range Installers {
installers = append(installers, name)
}
sort.Strings(installers)
return
}
type VersionNotFoundErr struct {
Version string
}
func (e *VersionNotFoundErr) Error() string {
return "Version " + e.Version + " not found"
}
type AssetNotFoundErr struct {
Version string
Asset string
}
func (e *AssetNotFoundErr) Error() string {
return "Asset " + e.Asset + " is not found in version " + e.Version
}