Skip to content

Instantly share code, notes, and snippets.

@jryannel
Created June 22, 2022 11:30
Show Gist options
  • Save jryannel/0be1927af171399b2886f05f3a71aef0 to your computer and use it in GitHub Desktop.
Save jryannel/0be1927af171399b2886f05f3a71aef0 to your computer and use it in GitHub Desktop.
check if string is url or local dir
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