diff options
| author | Fuwn <[email protected]> | 2024-10-12 00:32:09 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-12 00:32:12 -0700 |
| commit | 61f874213a60c83ccbbb9d86bbb6466a2f356c41 (patch) | |
| tree | c1acffdd062c720d480bb85a6530040476b0da0b /yae.go | |
| parent | 86b4d70fa5ea0c5215571e1af28b1b6f4ed1010a (diff) | |
| download | yae-61f874213a60c83ccbbb9d86bbb6466a2f356c41.tar.xz yae-61f874213a60c83ccbbb9d86bbb6466a2f356c41.zip | |
refactor(utilities): move shared utilities to separate file
Diffstat (limited to 'yae.go')
| -rw-r--r-- | yae.go | 36 |
1 files changed, 0 insertions, 36 deletions
@@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "os/exec" "strings" "time" @@ -254,38 +253,3 @@ func main() { os.Exit(1) } } - -func fetchSHA256(url string, unpack bool, show bool) (string, error) { - arguments := []string{"--type", "sha256", url} - - if unpack { - arguments = append([]string{"--unpack"}, arguments...) - } - - output, err := command("nix-prefetch-url", show, arguments...) - - if err != nil { - return "", err - } - - lines := strings.Split(output, "\n") - - return strings.Trim(lines[len(lines)-2], "\n"), nil -} - -func command(name string, show bool, args ...string) (string, error) { - executable, err := exec.LookPath(name) - out := []byte{} - - if show { - cmd := exec.Command(executable, args...) - cmd.Stdin = os.Stdin - cmd.Stderr = os.Stderr - out, err = cmd.Output() - } else { - cmd := exec.Command(executable, args...) - out, err = cmd.Output() - } - - return string(out), err -} |