Commits

Dobrosław Żybort  committed 636910b

Remove list error ErrBounds (Go'll panic if index < 0)

  • Participants
  • Parent commits ef9bf16

Comments (0)

Files changed (2)

 var (
 	// ErrRange is returned when index is bigger than list length
 	ErrRange = errors.New("Index out of range")
-	// ErrBounds is returned when index is smaller than 0
-	ErrBounds = errors.New("Index out of bounds")
 	// ErrRemoveFromEmptyList is returned when user want to remove element
 	// from empty list
 	ErrRemoveFromEmptyList = errors.
 	if len(*list) <= 0 {
 		return ErrRemoveFromEmptyList
 	}
-	if index < 0 {
-		return ErrBounds
-	}
 
 	listLen := len(*list)
 	if index >= listLen {
 	if len(*list) <= 0 {
 		return nil, ErrRemoveFromEmptyList
 	}
-	if index < 0 {
-		return nil, ErrBounds
-	}
 
 	listLen := len(*list)
 	if index >= listLen {

File list_test.go

 	{List{"one", "two", "three"}, 1, List{"one", "three"}, nil},
 	{List{"one"}, 0, List{}, nil},
 	{List{"one"}, 1, List{"one"}, ErrRange},
-	{List{"one"}, -1, List{"one"}, ErrBounds},
 	{List{}, 0, List{}, ErrRemoveFromEmptyList},
 }