Last active
November 6, 2021 19:58
-
-
Save miguelmota/9ab72c5e342f833123c0b5cfd5aca468 to your computer and use it in GitHub Desktop.
Golang expand tilde home directory
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 strings.HasPrefix(path, "~/") { | |
path = filepath.Join(dir, path[2:]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since go 1.12
Found on https://stackoverflow.com/a/13004756