Skip to content

Commit 852d839

Browse files
committed
Fix lint error in chess
1 parent cbd381d commit 852d839

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

chess/chess.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@ import (
55
"math"
66
)
77

8-
var invalidSquareErr = errors.New("invalid square")
8+
var errInvalidSquare = errors.New("invalid square")
99

1010
// Knights can attack when seperated by 2 squares in one direction and 1 square in the other direction.
1111
// Horizontal axis is called 'file' labelled from 'a' to 'f'
1212
// Forward axis is called 'rank' labelled from 1 to 8
1313
func CanKnightAttack(white, black string) (bool, error) {
1414
// square must have 2 characters
1515
if len(white) != 2 || len(black) != 2 {
16-
return true, invalidSquareErr
16+
return true, errInvalidSquare
1717
}
1818

1919
// cannot be on the same square
2020
if white == black {
21-
return false, invalidSquareErr
21+
return false, errInvalidSquare
2222
}
2323

2424
// assign integer values (1 - 8) to file letters and rank digits
2525
wFile := int(white[0] - 'a' + 1)
2626
if wFile < 1 || wFile > 8 {
27-
return false, invalidSquareErr
27+
return false, errInvalidSquare
2828
}
2929

3030
bFile := int(black[0] - 'a' + 1)
3131
if bFile < 1 || bFile > 8 {
32-
return false, invalidSquareErr
32+
return false, errInvalidSquare
3333
}
3434

3535
wRank := int(white[1] - '1' + 1)
3636
if wRank < 1 || wRank > 8 {
37-
return false, invalidSquareErr
37+
return false, errInvalidSquare
3838
}
3939

4040
bRank := int(black[1] - '1' + 1)
4141
if bRank < 1 || bRank > 8 {
42-
return false, invalidSquareErr
42+
return false, errInvalidSquare
4343
}
4444

4545
// check file and rank relative positions

0 commit comments

Comments
 (0)