There is no sparse slices in Go, so you could simply check the length:
if len(mySlice) > 3 {
// ...
}
If the length is greater than 3, you know that the index 3 and all those before that exist.
There is no sparse slices in Go, so you could simply check the length:
if len(mySlice) > 3 {
// ...
}
If the length is greater than 3, you know that the index 3 and all those before that exist.