refactor: go modernisation fixes
This commit is contained in:
1 parent
8e4923991d
commit
b2da85ead1
14 files changed
+41
-53
No files matched your search
@@ -11,6 +11,7 @@ package builtin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -116,8 +117,8 @@ func TruncateTail(content string, maxLines, maxBytes int) TruncationResult {
|
||||
byteCount := 0
|
||||
lineCount := 0
|
||||
|
||||
for i := len(lines) - 1; i >= 0; i-- {
|
||||
lineLen := len(lines[i])
|
||||
for i, line := range slices.Backward(lines) {
|
||||
lineLen := len(line)
|
||||
if i < len(lines)-1 {
|
||||
lineLen++ // account for the \n
|
||||
}
|
||||
|
||||
@@ -342,8 +342,8 @@ func (r *Registry) Stop(ctx context.Context) error {
|
||||
|
||||
var errs []error
|
||||
var failed []runningProvider
|
||||
for i := len(running) - 1; i >= 0; i-- {
|
||||
current := running[i]
|
||||
for _, current := range slices.Backward(running) {
|
||||
|
||||
r.index.Unregister(current.toolNames...)
|
||||
if err := safeStop(ctx, current.registration.engine); err != nil {
|
||||
failed = append(failed, current)
|
||||
@@ -495,8 +495,8 @@ func rollback(
|
||||
) ([]runningProvider, error) {
|
||||
var errs []error
|
||||
var failed []runningProvider
|
||||
for i := len(started) - 1; i >= 0; i-- {
|
||||
current := started[i]
|
||||
for _, current := range slices.Backward(started) {
|
||||
|
||||
index.Unregister(current.toolNames...)
|
||||
if err := safeStop(ctx, current.registration.engine); err != nil {
|
||||
failed = append(failed, current)
|
||||
|
||||
Reference in new issue
Block a user