Created
December 3, 2024 07:10
-
-
Save Integralist/d21ee193a83fdf68bc3fa506f25782fe to your computer and use it in GitHub Desktop.
[Delete a slice entry in Go] #go #golang #slices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zones == complete list of dns zones | |
// denyList == list of zones to remove | |
for _, deniedZone := range denyList { | |
for i := 0; i < len(zones); i++ { | |
if zones[i] == deniedZone { | |
zones = append(zones[:i], zones[i+1:]...) | |
i-- // Adjust index to stay at the correct position after removal | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment