ldd: separate Parse from Exec and trim space
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
18
ldd/exec.go
Normal file
18
ldd/exec.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package ldd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Exec(p string) ([]*Entry, error) {
|
||||
t := exec.Command("ldd", p)
|
||||
t.Stdout, t.Stderr = new(strings.Builder), os.Stderr
|
||||
if err := t.Run(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return Parse(t.Stdout.(fmt.Stringer))
|
||||
}
|
||||
Reference in New Issue
Block a user