From 79b91f453f62106ef34fad7d7fcf1eaea4325b48 Mon Sep 17 00:00:00 2001 From: Aaron Gibson Date: Mon, 1 Dec 2025 15:24:13 +0000 Subject: [PATCH] fix err "non-constant format string in call to fmt.Fprintf" --- cmd/ooniprobe/internal/log/handlers/cli/cli.go | 8 ++++---- .../internal/log/handlers/cli/measurements.go | 14 +++++++------- cmd/ooniprobe/internal/log/handlers/cli/results.go | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/ooniprobe/internal/log/handlers/cli/cli.go b/cmd/ooniprobe/internal/log/handlers/cli/cli.go index 13248525d1..4067ec56af 100644 --- a/cmd/ooniprobe/internal/log/handlers/cli/cli.go +++ b/cmd/ooniprobe/internal/log/handlers/cli/cli.go @@ -66,9 +66,9 @@ func logSectionTitle(w io.Writer, f log.Fields) error { colWidth := 24 title := f.Get("title").(string) - fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n") + fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth+2)) fmt.Fprintf(w, "┃ %s ┃\n", utils.RightPad(title, colWidth)) - fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n") + fmt.Fprintf(w, "┗%s┛\n", strings.Repeat("━", colWidth+2)) return nil } @@ -91,13 +91,13 @@ func logTable(w io.Writer, f log.Fields) error { } } - fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n") + fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth+2)) for _, line := range lines { fmt.Fprintf(w, "┃ %s ┃\n", utils.RightPad(line, colWidth), ) } - fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n") + fmt.Fprintf(w, "┗%s┛\n", strings.Repeat("━", colWidth+2)) return nil } diff --git a/cmd/ooniprobe/internal/log/handlers/cli/measurements.go b/cmd/ooniprobe/internal/log/handlers/cli/measurements.go index cf1f02299b..60fa0565aa 100644 --- a/cmd/ooniprobe/internal/log/handlers/cli/measurements.go +++ b/cmd/ooniprobe/internal/log/handlers/cli/measurements.go @@ -34,7 +34,7 @@ func logTestKeys(w io.Writer, testKeys string) error { testKeysLines[len(testKeysLines)-1] = testKeysLines[len(testKeysLines)-1] + "}" } for _, line := range testKeysLines { - fmt.Fprintf(w, fmt.Sprintf("│ %s │\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n", utils.RightPad(line, colWidth*2))) } return nil @@ -61,30 +61,30 @@ func logMeasurementItem(w io.Writer, f log.Fields) error { isFirst := f.Get("is_first").(bool) isLast := f.Get("is_last").(bool) if isFirst { - fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth*2+2)+"┓\n") + fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth*2+2)) } else { - fmt.Fprintf(w, "┢"+strings.Repeat("━", colWidth*2+2)+"┪\n") + fmt.Fprintf(w, "┢%s┪\n", strings.Repeat("━", colWidth*2+2)) } anomalyStr := fmt.Sprintf("ok: %s", statusIcon(!isAnomaly)) uploadStr := fmt.Sprintf("uploaded: %s", statusIcon(isUploaded)) failureStr := fmt.Sprintf("success: %s", statusIcon(!isFailed)) - fmt.Fprintf(w, fmt.Sprintf("│ %s │\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n", utils.RightPad( fmt.Sprintf("#%d", rID), colWidth*2))) if url != "" { - fmt.Fprintf(w, fmt.Sprintf("│ %s │\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n", utils.RightPad( fmt.Sprintf("%s (%s)", url, urlCategoryCode), colWidth*2))) } - fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n", utils.RightPad(testName, colWidth), utils.RightPad(anomalyStr, colWidth))) - fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n", utils.RightPad(failureStr, colWidth), utils.RightPad(uploadStr, colWidth))) diff --git a/cmd/ooniprobe/internal/log/handlers/cli/results.go b/cmd/ooniprobe/internal/log/handlers/cli/results.go index 9dd1deb2c3..e5e058c3e4 100644 --- a/cmd/ooniprobe/internal/log/handlers/cli/results.go +++ b/cmd/ooniprobe/internal/log/handlers/cli/results.go @@ -103,27 +103,27 @@ func logResultItem(w io.Writer, f log.Fields) error { index := f.Get("index").(int) totalCount := f.Get("total_count").(int) if index == 0 { - fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth*2+2)+"┓\n") + fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth*2+2)) } else { - fmt.Fprintf(w, "┢"+strings.Repeat("━", colWidth*2+2)+"┪\n") + fmt.Fprintf(w, "┢%s┪\n", strings.Repeat("━", colWidth*2+2)) } firstRow := utils.RightPad(fmt.Sprintf("#%d - %s", rID, startTime.Format(time.RFC822)), colWidth*2) - fmt.Fprintf(w, "┃ "+firstRow+" ┃\n") - fmt.Fprintf(w, "┡"+strings.Repeat("━", colWidth*2+2)+"┩\n") + fmt.Fprintf(w, "┃ %s ┃\n", firstRow) + fmt.Fprintf(w, "┡%s┩\n",strings.Repeat("━", colWidth*2+2)) summary := makeSummary(name, f.Get("measurement_count").(uint64), f.Get("measurement_anomaly_count").(uint64), f.Get("test_keys").(string)) - fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n", utils.RightPad(name, colWidth), utils.RightPad(summary[0], colWidth))) - fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n", utils.RightPad(networkName, colWidth), utils.RightPad(summary[1], colWidth))) - fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n", + fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n", utils.RightPad(asn, colWidth), utils.RightPad(summary[2], colWidth)))