ldd: separate Parse from Exec and trim space

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
2024-10-09 23:51:15 +09:00
parent 22dfa73efe
commit d41b9d2d9c
5 changed files with 139 additions and 31 deletions

18
ldd/exec.go Normal file
View 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))
}