Created
June 22, 2022 11:30
-
-
Save jryannel/0be1927af171399b2886f05f3a71aef0 to your computer and use it in GitHub Desktop.
check if string is url or local dir
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
func IsUrl(path string) bool { | |
u, err := url.Parse(path) | |
return err == nil && u.Scheme != "" && u.Host != "" | |
} | |
func IsDir(path string) bool { | |
s, err := os.Stat(path) | |
return s.IsDir() && os.IsExist(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment