Created
January 29, 2020 20:31
-
-
Save olafkotur/d98caf366ba9d2fbd97733c77c22a81d to your computer and use it in GitHub Desktop.
Array manipulation in Golang
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
// 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