From d25c2cba801cbaa9f9c0d5a92b90f153630ffe24 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 21 Aug 2026 15:52:02 +0200 Subject: Upgrade to Go 1.27 and apply go fix modernization --- cli/cli.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'cli') diff --git a/cli/cli.go b/cli/cli.go index 3f291bb..52b5a8c 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -106,10 +106,7 @@ func runBacktest(db *sql.DB) error { }) w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintln(w, "computed\treference\terr %\tride") - limit := 10 - if len(samples) < limit { - limit = len(samples) - } + limit := min(len(samples), 10) for _, s := range samples[:limit] { fmt.Fprintf(w, "%s\t%s\t%+.1f\t%s (%s)\n", s.computed.Round(time.Second), s.reference.Round(time.Second), s.relErrorPct, s.name, s.externalID) } @@ -162,10 +159,7 @@ func errorDistribution(absErrors []float64, percentiles []float64) map[float64]f sort.Float64s(sorted) distribution := map[float64]float64{} for _, p := range percentiles { - index := int(math.Ceil(p/100*float64(len(sorted))) - 1) - if index < 0 { - index = 0 - } + index := max(int(math.Ceil(p/100*float64(len(sorted)))-1), 0) if index >= len(sorted) { index = len(sorted) - 1 } -- cgit v1.3