diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-06-08 14:19:11 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-06-08 14:58:24 +0900 |
| commit | f869ff95a12756de97827b4afd93763f9661f144 (patch) | |
| tree | 6f5445ae623f44ceb99c8f7ddb5bb4cd1fb04aa0 /internal/outcome | |
| parent | 725f2e0ef3eaba1ad46b597604a684125ab93911 (diff) | |
all: apply modernisers
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/outcome')
| -rw-r--r-- | internal/outcome/finalise.go | 3 | ||||
| -rw-r--r-- | internal/outcome/hsu.go | 10 | ||||
| -rw-r--r-- | internal/outcome/process.go | 6 | ||||
| -rw-r--r-- | internal/outcome/shim.go | 4 |
4 files changed, 10 insertions, 13 deletions
diff --git a/internal/outcome/finalise.go b/internal/outcome/finalise.go index d74c648c..4049b8d3 100644 --- a/internal/outcome/finalise.go +++ b/internal/outcome/finalise.go @@ -58,8 +58,7 @@ func (k *outcome) finalise( supp := make([]string, len(config.Groups)) for i, name := range config.Groups { if gid, err := k.lookupGroupId(name); err != nil { - var unknownGroupError user.UnknownGroupError - if errors.As(err, &unknownGroupError) { + if unknownGroupError, ok := errors.AsType[user.UnknownGroupError](err); ok { return newWithMessageError(fmt.Sprintf("unknown group %q", name), unknownGroupError) } else { return &hst.AppError{Step: "look up group by name", Err: err, Msg: err.Error()} diff --git a/internal/outcome/hsu.go b/internal/outcome/hsu.go index 118fd681..ecb616c0 100644 --- a/internal/outcome/hsu.go +++ b/internal/outcome/hsu.go @@ -51,18 +51,16 @@ func (h *Hsu) ID() (int, error) { cmd.Stderr = os.Stderr // pass through fatal messages cmd.Env = make([]string, 0) cmd.Dir = fhs.Root - var ( - p []byte - exitError *exec.ExitError - ) - + var p []byte const step = "obtain uid from hsu" if p, h.idErr = h.k.cmdOutput(cmd); h.idErr == nil { h.id, h.idErr = strconv.Atoi(string(p)) if h.idErr != nil { h.idErr = &hst.AppError{Step: step, Err: h.idErr, Msg: "invalid uid string from hsu"} } - } else if errors.As(h.idErr, &exitError) && exitError != nil && exitError.ExitCode() == 1 { + } else if exitError, ok := errors.AsType[*exec.ExitError](h.idErr); ok && + exitError != nil && + exitError.ExitCode() == 1 { // hsu prints an error message in this case h.idErr = &hst.AppError{Step: step, Err: ErrHsuAccess} } else if errors.Is(h.idErr, os.ErrNotExist) { diff --git a/internal/outcome/process.go b/internal/outcome/process.go index 67851edc..614b22fc 100644 --- a/internal/outcome/process.go +++ b/internal/outcome/process.go @@ -328,11 +328,11 @@ func (k *outcome) main(msg message.Msg, identifierFd int) { } if err := k.sys.Revert((*system.Criteria)(&ec)); err != nil { - var joinError interface { + joinError, ok := errors.AsType[interface { Unwrap() []error error - } - if !errors.As(err, &joinError) || joinError == nil { + }](err) + if !ok || joinError == nil { perror(err, "revert system setup") } else { for _, v := range joinError.Unwrap() { diff --git a/internal/outcome/shim.go b/internal/outcome/shim.go index b2074928..6e039b65 100644 --- a/internal/outcome/shim.go +++ b/internal/outcome/shim.go @@ -390,8 +390,8 @@ func shimEntrypoint(k syscallDispatcher) { if err := k.containerWait(z); err != nil { sp.destroy() - var exitError *exec.ExitError - if !errors.As(err, &exitError) { + exitError, ok := errors.AsType[*exec.ExitError](err) + if !ok { if errors.Is(err, context.Canceled) { k.exit(hst.ExitCancel) } |
