Skip to content

Instantly share code, notes, and snippets.

@olafkotur
Created January 29, 2020 20:31
Show Gist options
  • Save olafkotur/d98caf366ba9d2fbd97733c77c22a81d to your computer and use it in GitHub Desktop.
Save olafkotur/d98caf366ba9d2fbd97733c77c22a81d to your computer and use it in GitHub Desktop.
Array manipulation in Golang
// Removing: If you already know the index
someArray = append(someArray[:i], someArray[i+1:]...)
// Optional to remove multiple based on value
for i, value := range someArray {
if value == someOtherValue {
someArray = append(someArray[:i], someArray[i+1:]...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment