From b10face244983b89a6f8fe72f81e276a8907eb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Sun, 18 Feb 2024 14:19:07 -0800 Subject: [PATCH] chore: simplify Sequence logic Replace lambda with a simple addition --- color.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/color.go b/color.go index 1a216e9..7679444 100644 --- a/color.go +++ b/color.go @@ -75,17 +75,15 @@ func (c NoColor) Sequence(_ bool) string { // Sequence returns the ANSI Sequence for the color. func (c ANSIColor) Sequence(bg bool) string { col := int(c) - bgMod := func(c int) int { - if bg { - return c + 10 - } - return c + bgMod := 0 + if bg { + bgMod = 10 } if col < 8 { - return fmt.Sprintf("%d", bgMod(col)+30) + return fmt.Sprintf("%d", bgMod+col+30) } - return fmt.Sprintf("%d", bgMod(col-8)+90) + return fmt.Sprintf("%d", bgMod+(col-8)+90) } // Sequence returns the ANSI Sequence for the color.