Skip to content

Instantly share code, notes, and snippets.

@ronaldwolvers
Last active February 25, 2023 14:27
Show Gist options
  • Select an option

  • Save ronaldwolvers/01dd0f0076f8a55f7787446a790a3a3b to your computer and use it in GitHub Desktop.

Select an option

Save ronaldwolvers/01dd0f0076f8a55f7787446a790a3a3b to your computer and use it in GitHub Desktop.
//Tested with Go 1.19
func RemoveElementFromSliceAtIndex[type_param any](s []type_param, index int) []type_param {
return append (s[:index], s[index+1:]...)
}
//Calling the function
RemoveElementFromSliceAtIndex[Your_Type](slice, index_of_item_to_remove)
//This function cannot be called while looping as the item at index_of_item_to_remove+1 will reside at index_of_item_to_remove after calling this function!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment