Skip to content

Commit

Permalink
Move check and return error earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Sep 20, 2024
1 parent b68404a commit 35e674d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions imagex/colorx/colorx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ var errInvalidFormat = errors.New("invalid format")
//
// For details, see https://stackoverflow.com/a/54200713/1705598
func ParseHexColor(s string) (c color.RGBA, err error) {
c.A = 0xff

if len(s) == 0 || s[0] != '#' {
return c, errInvalidFormat
}

c.A = 0xff

hexToByte := func(b byte) byte {
switch {
case b >= '0' && b <= '9':
Expand Down

0 comments on commit 35e674d

Please sign in to comment.