Skip to content

Commit

Permalink
refactor: 删除不必要的 fmt.Sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Nov 9, 2023
1 parent 492f6a5 commit 7348bb6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions colors/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package colors

import (
"fmt"
"math"
"strconv"

Expand Down Expand Up @@ -145,7 +144,7 @@ func RGB(r, g, b uint8) Color {
// - HEX("ababab") ==> RGB(0xab, 0xab, 0xab)
func HEX(hex string) Color {
if len(hex) == 0 {
panic(fmt.Sprintf("无效的参数 hex"))
panic("无效的参数 hex")
}

if hex[0] == '#' {
Expand All @@ -157,7 +156,7 @@ func HEX(hex string) Color {
hex = string([]byte{hex[0], hex[0], hex[1], hex[1], hex[2], hex[2]})
case 6:
default:
panic(fmt.Sprintf("无效的参数 hex"))
panic("无效的参数 hex")
}

c, err := strconv.ParseInt(hex, 16, 32)
Expand Down

0 comments on commit 7348bb6

Please sign in to comment.