Skip to content

Instantly share code, notes, and snippets.

@johnpili
Last active September 26, 2022 03:23
Show Gist options
  • Save johnpili/84c3064d30a9b041c87e43ba4bcb63a2 to your computer and use it in GitHub Desktop.
Save johnpili/84c3064d30a9b041c87e43ba4bcb63a2 to your computer and use it in GitHub Desktop.
Golang RemoveEmpty String from an array
// removeEmptyStrings - Use this to remove empty string values inside an array.
// This happens when allocation is bigger and empty
func removeEmptyStrings(s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment