Go: expand user path
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
if path == "~" { | |
// In case of "~", which won't be caught by the "else if" | |
path = dir | |
} else if strings.HasPrefix(path, "~/") { | |
// Use strings.HasPrefix so we don't match paths like | |
// "/something/~/something/" | |
path = filepath.Join(dir, path[2:]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment