Last active
September 26, 2022 03:23
-
-
Save johnpili/84c3064d30a9b041c87e43ba4bcb63a2 to your computer and use it in GitHub Desktop.
Golang RemoveEmpty String from an array
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
// 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