Fix a bug that allowed castling even if squares were attacked #3
@ -80,9 +80,9 @@ func (b *Board) CheckAndPlay(move *types.Move) (bool, Violation) {
|
||||
}
|
||||
}
|
||||
|
||||
wasSpecialMove, err := tempBoard.handleSpecialMove(*move)
|
||||
if err != nil {
|
||||
return false, InvalidMove
|
||||
wasSpecialMove, violation := tempBoard.handleSpecialMove(*move)
|
||||
if violation != "" {
|
||||
return false, violation
|
||||
}
|
||||
|
||||
if !wasSpecialMove {
|
||||
@ -188,21 +188,21 @@ func (p Position) getCopyOfPosition() Position {
|
||||
return position
|
||||
}
|
||||
|
||||
func (b *Board) handleSpecialMove(move types.Move) (bool, error) {
|
||||
func (b *Board) handleSpecialMove(move types.Move) (bool, Violation) {
|
||||
var was bool
|
||||
var err error
|
||||
var violation Violation
|
||||
var pieceAtStartSquare = b.getPieceAt(move.StartSquare)
|
||||
|
||||
switch piece := pieceAtStartSquare.(type) {
|
||||
case Pawn:
|
||||
was, err = piece.HandlePossiblePromotion(b, move)
|
||||
was, violation = piece.HandlePossiblePromotion(b, move)
|
||||
if !was {
|
||||
was, err = piece.HandleEnPassant(b, move, b.getLastMove())
|
||||
was, violation = piece.HandleEnPassant(b, move, b.getLastMove())
|
||||
}
|
||||
case King:
|
||||
was, err = piece.HandleCastling(b, move)
|
||||
was, violation = piece.HandleCastling(b, move)
|
||||
}
|
||||
return was, err
|
||||
return was, violation
|
||||
}
|
||||
|
||||
type GameEndedReason string
|
||||
|
158
chess/board_castling_test.go
Normal file
158
chess/board_castling_test.go
Normal file
@ -0,0 +1,158 @@
|
||||
package chess
|
||||
|
||||
import (
|
||||
"mchess_server/types"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_Board_WhiteCastlesLeft_QueenCoversSquareInBetween(t *testing.T) {
|
||||
board := newBoard()
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 1}] = King{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 1, Row: 1}] = Rook{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 4, Row: 5}] = Queen{Color: types.Black}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 1},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 1},
|
||||
ColorMoved: types.White,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
||||
|
||||
func Test_Board_WhiteCastlesRight_QueenCoversSquareInBetween(t *testing.T) {
|
||||
board := newBoard()
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 1}] = King{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 8, Row: 1}] = Rook{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 6, Row: 5}] = Queen{Color: types.Black}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 1},
|
||||
EndSquare: types.Coordinate{Col: 7, Row: 1},
|
||||
ColorMoved: types.White,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
||||
|
||||
func Test_Board_WhiteCastlesLeft_KingInCheck(t *testing.T) {
|
||||
board := newBoard()
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 1}] = King{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 1, Row: 1}] = Rook{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 5, Row: 5}] = Queen{Color: types.Black}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 1},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 1},
|
||||
ColorMoved: types.White,
|
||||
}
|
||||
|
||||
valid, violation := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
assert.Equal(t, CastlingWhileKingInCheck, violation)
|
||||
}
|
||||
|
||||
func Test_Board_WhiteCastlesLeft_QueenCoversKingsSquare(t *testing.T) {
|
||||
board := newBoard()
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 1}] = King{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 1, Row: 1}] = Rook{Color: types.White}
|
||||
board.position[types.Coordinate{Col: 3, Row: 5}] = Queen{Color: types.Black}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 1},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 1},
|
||||
ColorMoved: types.White,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
||||
|
||||
func Test_Board_BlackCastlesLeft_QueenCoversSquareInBetween(t *testing.T) {
|
||||
board := newBoard()
|
||||
board.colorToMove = types.Black
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 8}] = King{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 1, Row: 8}] = Rook{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 4, Row: 4}] = Queen{Color: types.White}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 8},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 8},
|
||||
ColorMoved: types.Black,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
||||
|
||||
func Test_Board_BlackCastlesRight_QueenCoversSquareInBetween(t *testing.T) {
|
||||
board := newBoard()
|
||||
board.colorToMove = types.Black
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 8}] = King{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 8, Row: 8}] = Rook{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 6, Row: 4}] = Queen{Color: types.White}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 8},
|
||||
EndSquare: types.Coordinate{Col: 7, Row: 8},
|
||||
ColorMoved: types.Black,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
||||
|
||||
func Test_Board_BlackCastlesLeft_KingInCheck(t *testing.T) {
|
||||
board := newBoard()
|
||||
board.colorToMove = types.Black
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 8}] = King{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 1, Row: 8}] = Rook{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 5, Row: 4}] = Queen{Color: types.White}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 8},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 8},
|
||||
ColorMoved: types.Black,
|
||||
}
|
||||
|
||||
valid, violation := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
assert.Equal(t, CastlingWhileKingInCheck, violation)
|
||||
}
|
||||
|
||||
func Test_Board_BlackCastlesLeft_QueenCoversKingsSquare(t *testing.T) {
|
||||
board := newBoard()
|
||||
board.colorToMove = types.Black
|
||||
|
||||
board.position[types.Coordinate{Col: 5, Row: 8}] = King{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 1, Row: 8}] = Rook{Color: types.Black}
|
||||
board.position[types.Coordinate{Col: 3, Row: 4}] = Queen{Color: types.White}
|
||||
|
||||
castling := types.Move{
|
||||
StartSquare: types.Coordinate{Col: 5, Row: 8},
|
||||
EndSquare: types.Coordinate{Col: 3, Row: 8},
|
||||
ColorMoved: types.Black,
|
||||
}
|
||||
|
||||
valid, _ := board.CheckAndPlay(&castling)
|
||||
|
||||
assert.False(t, valid)
|
||||
}
|
@ -29,25 +29,22 @@ func (k King) AfterMoveAction(board *Board, fromSquare types.Coordinate) {
|
||||
}
|
||||
}
|
||||
|
||||
func (k King) HandleCastling(board *Board, move types.Move) (bool, error) {
|
||||
func (k King) HandleCastling(board *Board, move types.Move) (bool, Violation) {
|
||||
if k.hadMovedBefore(board) {
|
||||
return false, nil
|
||||
return false, ""
|
||||
}
|
||||
|
||||
valid, dir := k.movedOnValidCastlingSquare(board, move)
|
||||
if board.isSquareAttacked(move.StartSquare, k.Color.Opposite()) {
|
||||
return false, CastlingWhileKingInCheck
|
||||
}
|
||||
|
||||
valid, dir := k.isCastlingAllowed(board, move)
|
||||
if !valid {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
switch k.Color {
|
||||
case types.White:
|
||||
board.state.WhiteKingMoved = true
|
||||
case types.Black:
|
||||
board.state.BlackKingMoved = true
|
||||
return false, ""
|
||||
}
|
||||
|
||||
k.playCastlingOnBoard(board, move, dir)
|
||||
return true, nil
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func (k King) hadMovedBefore(b *Board) bool {
|
||||
@ -64,52 +61,61 @@ func (k King) hadMovedBefore(b *Board) bool {
|
||||
type CastlingDirection string
|
||||
|
||||
const (
|
||||
NoDirection CastlingDirection = ""
|
||||
CastlingRight CastlingDirection = "right"
|
||||
CastlingLeft CastlingDirection = "left"
|
||||
)
|
||||
|
||||
func (k King) movedOnValidCastlingSquare(b *Board, move types.Move) (bool, CastlingDirection) {
|
||||
func (k King) isCastlingAllowed(b *Board, move types.Move) (bool, CastlingDirection) {
|
||||
|
||||
var valid = false
|
||||
|
||||
switch k.Color {
|
||||
case types.White:
|
||||
castlingSquareRight := types.Coordinate{Col: 7, Row: 1}
|
||||
castlingSquareLeft := types.Coordinate{Col: 3, Row: 1}
|
||||
destinationSquareForKingRight := types.Coordinate{Col: 7, Row: 1}
|
||||
destinationSquareForKingLeft := types.Coordinate{Col: 3, Row: 1}
|
||||
|
||||
if move.EndSquare == castlingSquareRight &&
|
||||
b.getPieceAt(castlingSquareRight) == nil &&
|
||||
b.getPieceAt(*castlingSquareRight.Left(1)) == nil &&
|
||||
if move.EndSquare == destinationSquareForKingRight &&
|
||||
b.getPieceAt(destinationSquareForKingRight) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingRight.Left(1)) == nil &&
|
||||
!b.isSquareAttacked(destinationSquareForKingRight, types.Black) &&
|
||||
!b.isSquareAttacked(*destinationSquareForKingRight.Left(1), types.Black) &&
|
||||
!b.state.WhiteHRookMoved {
|
||||
return true, CastlingRight
|
||||
}
|
||||
|
||||
if move.EndSquare == castlingSquareLeft &&
|
||||
b.getPieceAt(castlingSquareLeft) == nil &&
|
||||
b.getPieceAt(*castlingSquareLeft.Right(1)) == nil &&
|
||||
b.getPieceAt(*castlingSquareLeft.Left(1)) == nil &&
|
||||
if move.EndSquare == destinationSquareForKingLeft &&
|
||||
b.getPieceAt(destinationSquareForKingLeft) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingLeft.Right(1)) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingLeft.Left(1)) == nil &&
|
||||
!b.isSquareAttacked(destinationSquareForKingLeft, types.Black) &&
|
||||
!b.isSquareAttacked(*destinationSquareForKingLeft.Right(1), types.Black) &&
|
||||
!b.state.WhiteARookMoved {
|
||||
return true, CastlingLeft
|
||||
}
|
||||
case types.Black:
|
||||
castlingSquareRight := types.Coordinate{Col: 7, Row: 8}
|
||||
castlingSquareLeft := types.Coordinate{Col: 3, Row: 8}
|
||||
destinationSquareForKingRight := types.Coordinate{Col: 7, Row: 8}
|
||||
destinationSquareForKingLeft := types.Coordinate{Col: 3, Row: 8}
|
||||
|
||||
if move.EndSquare == castlingSquareRight &&
|
||||
b.getPieceAt(castlingSquareRight) == nil &&
|
||||
b.getPieceAt(*castlingSquareRight.Left(1)) == nil &&
|
||||
if move.EndSquare == destinationSquareForKingRight &&
|
||||
b.getPieceAt(destinationSquareForKingRight) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingRight.Left(1)) == nil &&
|
||||
!b.isSquareAttacked(destinationSquareForKingRight, types.White) &&
|
||||
!b.isSquareAttacked(*destinationSquareForKingRight.Left(1), types.White) &&
|
||||
!b.state.BlackHRookMoved {
|
||||
return true, CastlingRight
|
||||
}
|
||||
|
||||
if move.EndSquare == castlingSquareLeft &&
|
||||
b.getPieceAt(castlingSquareLeft) == nil &&
|
||||
b.getPieceAt(*castlingSquareLeft.Right(1)) == nil &&
|
||||
b.getPieceAt(*castlingSquareLeft.Left(1)) == nil &&
|
||||
if move.EndSquare == destinationSquareForKingLeft &&
|
||||
b.getPieceAt(destinationSquareForKingLeft) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingLeft.Right(1)) == nil &&
|
||||
b.getPieceAt(*destinationSquareForKingLeft.Left(1)) == nil &&
|
||||
!b.isSquareAttacked(destinationSquareForKingLeft, types.White) &&
|
||||
!b.isSquareAttacked(*destinationSquareForKingLeft.Right(1), types.White) &&
|
||||
!b.state.BlackARookMoved {
|
||||
return true, CastlingLeft
|
||||
}
|
||||
}
|
||||
return valid, CastlingRight
|
||||
return valid, NoDirection
|
||||
}
|
||||
|
||||
func (k King) playCastlingOnBoard(board *Board, move types.Move, dir CastlingDirection) {
|
||||
|
@ -32,7 +32,7 @@ func (p Pawn) GetColor() types.ChessColor {
|
||||
return p.Color
|
||||
}
|
||||
|
||||
func (p *Pawn) HandlePossiblePromotion(b *Board, move types.Move) (bool, error) {
|
||||
func (p *Pawn) HandlePossiblePromotion(b *Board, move types.Move) (bool, Violation) {
|
||||
var isPromotionMove bool
|
||||
var promotionToPiece types.PieceShortName
|
||||
|
||||
@ -62,14 +62,14 @@ func (p *Pawn) HandlePossiblePromotion(b *Board, move types.Move) (bool, error)
|
||||
b.position[move.EndSquare] = GetPieceForShortName(promotionToPiece)
|
||||
}
|
||||
|
||||
return isPromotionMove, nil
|
||||
return isPromotionMove, ""
|
||||
}
|
||||
|
||||
func (p *Pawn) HandleEnPassant(b *Board, move, lastMove types.Move) (bool, error) {
|
||||
func (p *Pawn) HandleEnPassant(b *Board, move, lastMove types.Move) (bool, Violation) {
|
||||
var wasEnPassant bool
|
||||
|
||||
if lastMove.PieceMoved.ToCommon() != types.PawnShortName {
|
||||
return false, nil
|
||||
return false, ""
|
||||
}
|
||||
|
||||
switch move.ColorMoved {
|
||||
@ -127,7 +127,7 @@ func (p *Pawn) HandleEnPassant(b *Board, move, lastMove types.Move) (bool, error
|
||||
b.position[move.EndSquare] = GetPieceForShortName(move.PieceMoved)
|
||||
}
|
||||
|
||||
return wasEnPassant, nil
|
||||
return wasEnPassant, ""
|
||||
}
|
||||
func (p Pawn) getAllMoves(fromSquare types.Coordinate) []types.Coordinate {
|
||||
theoreticalMoves := make([]types.Coordinate, 0, 4)
|
||||
|
@ -3,12 +3,14 @@ package chess
|
||||
type Violation string
|
||||
|
||||
var (
|
||||
InvalidMove Violation = "invalid move"
|
||||
NoPieceAtStartSquare Violation = "no piece at start square"
|
||||
WrongColorMoved Violation = "wrong color moved"
|
||||
TargetSquareIsOccupied Violation = "target square is occupied"
|
||||
KingInCheck Violation = "king would be in check after move"
|
||||
SomethingWentWrong Violation = "something went wrong"
|
||||
InvalidMove Violation = "invalid move"
|
||||
NoPieceAtStartSquare Violation = "no piece at start square"
|
||||
WrongColorMoved Violation = "wrong color moved"
|
||||
TargetSquareIsOccupied Violation = "target square is occupied"
|
||||
KingInCheck Violation = "king would be in check after move"
|
||||
SomethingWentWrong Violation = "something went wrong"
|
||||
CastlingThroughCheck Violation = "king would move through check"
|
||||
CastlingWhileKingInCheck Violation = "king cannot castle while in check"
|
||||
)
|
||||
|
||||
func (v Violation) String() string {
|
||||
|
22
go.mod
22
go.mod
@ -6,13 +6,13 @@ require (
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/samber/lo v1.39.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/tjarratt/babble v0.0.0-20210505082055-cbca2a4833c1
|
||||
nhooyr.io/websocket v1.8.10
|
||||
nhooyr.io/websocket v1.8.11
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.10.2 // indirect
|
||||
github.com/bytedance/sonic v1.11.3 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
@ -20,27 +20,27 @@ require (
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.17.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.19.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
github.com/onsi/gomega v1.27.10 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
golang.org/x/arch v0.7.0 // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.32.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
23
go.sum
23
go.sum
@ -2,6 +2,8 @@ github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1
|
||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
||||
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
|
||||
github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
||||
github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA=
|
||||
github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
|
||||
@ -31,6 +33,8 @@ github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqR
|
||||
github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74=
|
||||
github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4=
|
||||
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
@ -61,6 +65,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
@ -88,6 +94,8 @@ github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6
|
||||
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
|
||||
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
|
||||
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
|
||||
@ -97,6 +105,7 @@ github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@ -106,6 +115,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tjarratt/babble v0.0.0-20210505082055-cbca2a4833c1 h1:j8whCiEmvLCXI3scVn+YnklCU8mwJ9ZJ4/DGAKqQbRE=
|
||||
github.com/tjarratt/babble v0.0.0-20210505082055-cbca2a4833c1/go.mod h1:O5hBrCGqzfb+8WyY8ico2AyQau7XQwAfEQeEQ5/5V9E=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
@ -129,6 +140,8 @@ golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
|
||||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
|
||||
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
|
||||
@ -137,6 +150,8 @@ golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcs
|
||||
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
|
||||
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@ -149,6 +164,8 @@ golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -169,6 +186,8 @@ golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
@ -191,6 +210,8 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
@ -204,5 +225,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
|
||||
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
|
Loading…
Reference in New Issue
Block a user
This function is just ugly.
It checks a lot of things. The code for the black and white branches are almost the same. This should be done in multiple steps in a more systematic fashion.