Created
May 25, 2019 13:23
-
-
Save anonymouse64/c9794201575d62835cc9b9817da76825 to your computer and use it in GitHub Desktop.
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
// split a file path into all the elements of the path | |
func filePathElements(f string) []string { | |
paths := make([]string, 0) | |
fTemp := f | |
lastElem := "" | |
for fTemp != "" && fTemp != "/" { | |
fTemp, lastElem = filepath.Split(filepath.Clean(fTemp)) | |
paths = append([]string{lastElem}, paths...) | |
} | |
return paths | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment