Pull request: all: imp code, err handling

Closes #2571.

Squashed commit of the following:

commit a5b50ee011a995f4ab3d93314acd6f0ca82d99cf
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Mar 15 14:05:25 2021 +0300

    all: imp code

commit bc610f8f438549e8c6b04c8a213b5422dda2aff5
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 12 20:00:14 2021 +0300

    all: imp code, err handling
This commit is contained in:
Ainar Garipov
2021-03-15 14:19:04 +03:00
parent d970b79f2b
commit 313fd7107f
15 changed files with 121 additions and 99 deletions

View File

@@ -8,29 +8,12 @@ import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
// ContainsString checks if string is in the slice of strings.
func ContainsString(strs []string, str string) bool {
for _, s := range strs {
if s == str {
return true
}
}
return false
}
// FileExists returns true if file exists.
func FileExists(fn string) bool {
_, err := os.Stat(fn)
return err == nil || !os.IsNotExist(err)
}
// RunCommand runs shell command.
func RunCommand(command string, arguments ...string) (int, string, error) {
cmd := exec.Command(command, arguments...)