From 23d59f3133f5f5fbb5d1625057abf85e7a4d2afb Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 3 Sep 2026 19:22:23 +0200 Subject: [PATCH] refactor: adopt strings.Cut and strings.SplitSeq Applies what go fix now proposes, so make fmt is a no-op on a clean tree instead of dirtying these two files on every run. Both rewrites are equivalent: Cut's first result matches SplitN(s, sep, 2)[0], and SplitSeq iterates the same substrings without building the intermediate slice. --- pkg/modules/libreoffice/api/proxy_test.go | 2 +- pkg/modules/pdfcpu/optimize.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/modules/libreoffice/api/proxy_test.go b/pkg/modules/libreoffice/api/proxy_test.go index efb4dd14..6dc1015a 100644 --- a/pkg/modules/libreoffice/api/proxy_test.go +++ b/pkg/modules/libreoffice/api/proxy_test.go @@ -361,7 +361,7 @@ func TestSofficeProxyEnv_OverridesExisting(t *testing.T) { // Old proxy values must be gone, not duplicated. Count exact-case keys. counts := map[string]int{} for _, kv := range out { - key := strings.SplitN(kv, "=", 2)[0] + key, _, _ := strings.Cut(kv, "=") counts[key]++ } for _, key := range []string{"http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY", "no_proxy", "NO_PROXY"} { diff --git a/pkg/modules/pdfcpu/optimize.go b/pkg/modules/pdfcpu/optimize.go index 4f193ebd..ec64649f 100644 --- a/pkg/modules/pdfcpu/optimize.go +++ b/pkg/modules/pdfcpu/optimize.go @@ -180,7 +180,7 @@ func (engine *PdfCpu) listImages(ctx context.Context, inputPath string) ([]pdfcp // their second column is not a numeric object number. func parseImagesList(output string) []pdfcpuImage { var images []pdfcpuImage - for _, line := range strings.Split(output, "\n") { + for line := range strings.SplitSeq(output, "\n") { cols := strings.Split(line, "│") if len(cols) < 9 { continue