⛩️ Powerful yet Minimal Nix Dependency Manager
flake flakes home-manager nixos go nix dependency dependencies
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(utilities): move shared utilities to separate file

Fuwn 34888a8b cbd0c5c7

+42 -36
+42
utilities.go
··· 1 + package main 2 + 3 + import ( 4 + "os" 5 + "os/exec" 6 + "strings" 7 + ) 8 + 9 + func fetchSHA256(url string, unpack bool, show bool) (string, error) { 10 + arguments := []string{"--type", "sha256", url} 11 + 12 + if unpack { 13 + arguments = append([]string{"--unpack"}, arguments...) 14 + } 15 + 16 + output, err := command("nix-prefetch-url", show, arguments...) 17 + 18 + if err != nil { 19 + return "", err 20 + } 21 + 22 + lines := strings.Split(output, "\n") 23 + 24 + return strings.Trim(lines[len(lines)-2], "\n"), nil 25 + } 26 + 27 + func command(name string, show bool, args ...string) (string, error) { 28 + executable, err := exec.LookPath(name) 29 + out := []byte{} 30 + 31 + if show { 32 + cmd := exec.Command(executable, args...) 33 + cmd.Stdin = os.Stdin 34 + cmd.Stderr = os.Stderr 35 + out, err = cmd.Output() 36 + } else { 37 + cmd := exec.Command(executable, args...) 38 + out, err = cmd.Output() 39 + } 40 + 41 + return string(out), err 42 + }
-36
yae.go
··· 3 3 import ( 4 4 "fmt" 5 5 "os" 6 - "os/exec" 7 6 "strings" 8 7 "time" 9 8 ··· 254 253 os.Exit(1) 255 254 } 256 255 } 257 - 258 - func fetchSHA256(url string, unpack bool, show bool) (string, error) { 259 - arguments := []string{"--type", "sha256", url} 260 - 261 - if unpack { 262 - arguments = append([]string{"--unpack"}, arguments...) 263 - } 264 - 265 - output, err := command("nix-prefetch-url", show, arguments...) 266 - 267 - if err != nil { 268 - return "", err 269 - } 270 - 271 - lines := strings.Split(output, "\n") 272 - 273 - return strings.Trim(lines[len(lines)-2], "\n"), nil 274 - } 275 - 276 - func command(name string, show bool, args ...string) (string, error) { 277 - executable, err := exec.LookPath(name) 278 - out := []byte{} 279 - 280 - if show { 281 - cmd := exec.Command(executable, args...) 282 - cmd.Stdin = os.Stdin 283 - cmd.Stderr = os.Stderr 284 - out, err = cmd.Output() 285 - } else { 286 - cmd := exec.Command(executable, args...) 287 - out, err = cmd.Output() 288 - } 289 - 290 - return string(out), err 291 - }