-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmode_go.go
More file actions
26 lines (24 loc) · 790 Bytes
/
mode_go.go
File metadata and controls
26 lines (24 loc) · 790 Bytes
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
package installer
import (
"fmt"
)
// InstallGoInstall installs a tool via `go install source@moduleVersion`,
// then runs the installed binary with `-version t.Version` to perform
// the actual tool installation (e.g. tinygoinstall installs TinyGo).
func (i *Installer) InstallGoInstall(t Tool, d *Deps) error {
moduleVersion := t.ModuleVersion
if moduleVersion == "" {
moduleVersion = "latest"
}
source := fmt.Sprintf("%s@%s", t.Source, moduleVersion)
if _, err := d.RunCmd("go", "install", source); err != nil {
return fmt.Errorf("go install failed: %w", err)
}
if t.Version != "" {
out, err := d.RunCmd(t.Name, "-v", "-version", t.Version)
if err != nil {
return fmt.Errorf("%s -version %s failed: %w\n%s", t.Name, t.Version, err, string(out))
}
}
return nil
}