diff --git a/README.md b/README.md index f8db93f..381a7e2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ #### 组件工具 1. 安装 -> go install myschools.me/suguo/snippet/snippet@latest +> go install myschools.me/suguo/snippet@latest 2. 使用 > snippet -dl mysql diff --git a/snippet/main.go b/main.go similarity index 95% rename from snippet/main.go rename to main.go index 7e52b60..0dc9989 100644 --- a/snippet/main.go +++ b/main.go @@ -42,7 +42,8 @@ func main() { // get all file link and download it func dl(client http.Client, path string, wg *sync.WaitGroup) { - if !isExist(path) { + _, err := os.Stat(path) + if !os.IsNotExist(err) { os.MkdirAll(path, 0775) } @@ -112,9 +113,3 @@ func getHtml(client http.Client, url string) ([]byte, error) { } return data, nil } - -// if file or directory exits -func isExist(path string) bool { - _, err := os.Stat(path) - return !os.IsNotExist(err) -}