Skip to content

Instantly share code, notes, and snippets.

@xianlubird
Created June 20, 2016 08:25
Show Gist options
  • Save xianlubird/e98758f58b2cecc875e7e3723c5ba6d0 to your computer and use it in GitHub Desktop.
Save xianlubird/e98758f58b2cecc875e7e3723c5ba6d0 to your computer and use it in GitHub Desktop.
remove slice while loop a slice
for i := len(config.Applications) - 1; i >= 0; i-- {
application := config.Applications[i]
// Condition to decide if current element has to be deleted:
if haveToDelete {
config.Applications = append(config.Applications[:i],
config.Applications[i+1:]...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment