1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Use errcheck to find unhandled errors (#795)

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2019-12-17 08:26:16 -08:00
committed by GitHub
parent 04ff03ab1c
commit cde904ff08
44 changed files with 250 additions and 97 deletions

View File

@@ -92,26 +92,37 @@ func OpenFile(path string) {
if (strings.HasPrefix(path, "http://")) || (strings.HasPrefix(path, "https://")) {
if len(OpenUrlUtil) > 0 {
commands := append(OpenUrlUtil, path)
exec.Command(commands[0], commands[1:]...).Start()
cmd := exec.Command(commands[0], commands[1:]...)
err := cmd.Start()
if err != nil {
return
}
return
}
var cmd *exec.Cmd
switch runtime.GOOS {
case "linux":
exec.Command("xdg-open", path).Start()
cmd = exec.Command("xdg-open", path)
case "windows":
exec.Command("rundll32", "url.dll,FileProtocolHandler", path).Start()
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", path)
case "darwin":
exec.Command("open", path).Start()
cmd = exec.Command("open", path)
default:
// for the BSDs
exec.Command("xdg-open", path).Start()
cmd = exec.Command("xdg-open", path)
}
} else {
filePath, _ := ExpandHomeDir(path)
cmd := exec.Command(OpenFileUtil, filePath)
ExecuteCommand(cmd)
err := cmd.Start()
if err != nil {
return
}
return
}
filePath, _ := ExpandHomeDir(path)
cmd := exec.Command(OpenFileUtil, filePath)
ExecuteCommand(cmd)
}
// ReadFileBytes reads the contents of a file and returns those contents as a slice of bytes