Skip to content

Instantly share code, notes, and snippets.

@dpastoor
Created March 1, 2017 14:29
Show Gist options
  • Save dpastoor/89acd053edf21563940c32b22280ab7b to your computer and use it in GitHub Desktop.
Save dpastoor/89acd053edf21563940c32b22280ab7b to your computer and use it in GitHub Desktop.
if n == 0 && i == "~" {
if runtime.GOOS == "windows" {
i = os.Getenv("USERPROFILE")
} else {
i = os.Getenv("HOME")
}
}
for n, i := range strings.Split(filepath.ToSlash(pattern), "/") {
if root == "" && strings.Index(i, "*") != -1 {
if globmask == "" {
root = "."
} else {
root = filepath.ToSlash(globmask)
}
}
if n == 0 && i == "~" {
if runtime.GOOS == "windows" {
i = os.Getenv("USERPROFILE")
} else {
i = os.Getenv("HOME")
}
}
if envre.MatchString(i) {
i = strings.Trim(strings.Trim(os.Getenv(i[1:]), "()"), `"`)
}
globmask = filepath.Join(globmask, i)
if n == 0 {
if runtime.GOOS == "windows" && filepath.VolumeName(i) != "" {
globmask = i + "/"
} else if len(globmask) == 0 {
globmask = "/"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment