perf: use `exec.LookPath` to check the path of external application
This commit is contained in:
parent
4fd73411de
commit
c7c647d728
|
@ -17,8 +17,10 @@ type PreferencesStorage struct {
|
|||
}
|
||||
|
||||
func NewPreferences() *PreferencesStorage {
|
||||
storage := NewLocalStore("preferences.yaml")
|
||||
log.Printf("preferences path: %s\n", storage.ConfPath)
|
||||
return &PreferencesStorage{
|
||||
storage: NewLocalStore("preferences.yaml"),
|
||||
storage: storage,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package convutil
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type PhpConvert struct {
|
||||
CmdConvert
|
||||
}
|
||||
|
@ -47,7 +51,7 @@ func NewPhpConvert() *PhpConvert {
|
|||
}
|
||||
|
||||
var err error
|
||||
if _, err = runCommand(c.DecodePath, "-v"); err != nil {
|
||||
if _, err = exec.LookPath(c.DecodePath); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package convutil
|
||||
|
||||
import "os/exec"
|
||||
|
||||
type PickleConvert struct {
|
||||
CmdConvert
|
||||
}
|
||||
|
@ -40,9 +42,9 @@ func NewPickleConvert() *PickleConvert {
|
|||
}
|
||||
c.DecodePath, c.EncodePath = "python3", "python3"
|
||||
var err error
|
||||
if _, err = runCommand(c.DecodePath, "--version"); err != nil {
|
||||
if _, err = exec.LookPath(c.DecodePath); err != nil {
|
||||
c.DecodePath, c.EncodePath = "python", "python"
|
||||
if _, err = runCommand(c.DecodePath, "--version"); err != nil {
|
||||
if _, err = exec.LookPath(c.DecodePath); err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue