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 /cmd | |
| parent | 725f2e0ef3eaba1ad46b597604a684125ab93911 (diff) | |
all: apply modernisers
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/earlyinit/modprobe.go | 4 | ||||
| -rw-r--r-- | cmd/hakurei/json.go | 11 | ||||
| -rw-r--r-- | cmd/mbf/internal/pkgserver/search.go | 2 | ||||
| -rw-r--r-- | cmd/sharefs/fuse.go | 4 |
4 files changed, 11 insertions, 10 deletions
diff --git a/cmd/earlyinit/modprobe.go b/cmd/earlyinit/modprobe.go index 5a9868d4..8addf973 100644 --- a/cmd/earlyinit/modprobe.go +++ b/cmd/earlyinit/modprobe.go @@ -57,8 +57,8 @@ func dispatchModprobe( continue } - var exitError *exec.ExitError - if !errors.As(err, &exitError) || exitError == nil { + exitError, ok := errors.AsType[*exec.ExitError](err) + if !ok || exitError == nil { r.Dispatch(report.Degraded, "invoke modprobe", err) continue } diff --git a/cmd/hakurei/json.go b/cmd/hakurei/json.go index 30eb4334..d0d978d3 100644 --- a/cmd/hakurei/json.go +++ b/cmd/hakurei/json.go @@ -7,7 +7,8 @@ import ( "strconv" ) -// decodeJSON decodes json from r and stores it in v. A non-nil error results in a call to fatal. +// decodeJSON decodes json from r and stores it in v. A non-nil error results in +// a call to fatal. func decodeJSON(fatal func(v ...any), op string, r io.Reader, v any) { err := json.NewDecoder(r).Decode(v) if err == nil { @@ -47,14 +48,14 @@ func encodeJSON(fatal func(v ...any), output io.Writer, short bool, v any) { } if err := encoder.Encode(v); err != nil { - var marshalerError *json.MarshalerError - if errors.As(err, &marshalerError) && marshalerError != nil { + if e, ok := errors.AsType[*json.MarshalerError](err); ok && e != nil { // this likely indicates an implementation error in hst - fatal("cannot encode json for " + marshalerError.Type.String() + ": " + marshalerError.Err.Error()) + fatal("cannot encode json for " + e.Type.String() + ": " + e.Err.Error()) return } - // UnsupportedTypeError, UnsupportedValueError: incorrect usage, does not need to be handled + // UnsupportedTypeError, UnsupportedValueError: incorrect usage, does + // not need to be handled fatal("cannot write json: " + err.Error()) } } diff --git a/cmd/mbf/internal/pkgserver/search.go b/cmd/mbf/internal/pkgserver/search.go index 5756512f..15947804 100644 --- a/cmd/mbf/internal/pkgserver/search.go +++ b/cmd/mbf/internal/pkgserver/search.go @@ -74,7 +74,7 @@ func (s *searchCache) clean() { } func indexsum(in [][]int) int { sum := 0 - for i := 0; i < len(in); i++ { + for i := range in { sum += in[i][1] - in[i][0] } return sum diff --git a/cmd/sharefs/fuse.go b/cmd/sharefs/fuse.go index c9855eb7..5dfbf385 100644 --- a/cmd/sharefs/fuse.go +++ b/cmd/sharefs/fuse.go @@ -508,8 +508,8 @@ func _main(s ...string) (exitCode int) { if !z.AllowOrphan { if err := z.Wait(); err != nil { - var exitError *exec.ExitError - if !errors.As(err, &exitError) || exitError == nil { + exitError, ok := errors.AsType[*exec.ExitError](err) + if !ok || exitError == nil { log.Println(err) return 5 } |
