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

View File

@@ -1,11 +1,27 @@
package ldd
import "fmt"
import (
"errors"
"fmt"
)
type EntryUnexpectedSegmentsError struct {
Entry string
var (
ErrUnexpectedSeparator = errors.New("unexpected separator")
ErrPathNotAbsolute = errors.New("path not absolute")
ErrBadLocationFormat = errors.New("bad location format")
ErrUnexpectedNewline = errors.New("unexpected newline")
)
type EntryUnexpectedSegmentsError string
func (e EntryUnexpectedSegmentsError) Is(err error) bool {
var eq EntryUnexpectedSegmentsError
if !errors.As(err, &eq) {
return false
}
return e == eq
}
func (e *EntryUnexpectedSegmentsError) Error() string {
return fmt.Sprintf("unexpected segments in entry %q", e.Entry)
func (e EntryUnexpectedSegmentsError) Error() string {
return fmt.Sprintf("unexpected segments in entry %q", string(e))
}