Skip to content

Instantly share code, notes, and snippets.

@anonymouse64
Created May 25, 2019 13:23
Show Gist options
  • Save anonymouse64/c9794201575d62835cc9b9817da76825 to your computer and use it in GitHub Desktop.
Save anonymouse64/c9794201575d62835cc9b9817da76825 to your computer and use it in GitHub Desktop.
// 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