@@ -3,7 +3,6 @@ package utils
33import (
44 "errors"
55 "fmt"
6- "io/ioutil"
76 "os"
87 "path/filepath"
98)
@@ -37,8 +36,8 @@ func FileMove(src string, dst string) error {
3736 if err != nil {
3837 return err
3938 }
40- if ! oSrc .IsDir () {
41- return errors .New (fmt .Sprintf ("%s is not Dir" , src ))
39+ if oSrc .IsDir () {
40+ return errors .New (fmt .Sprintf ("%s is Dir" , src ))
4241 }
4342 oDst , err := os .Stat (dst )
4443 if err != nil {
@@ -47,15 +46,19 @@ func FileMove(src string, dst string) error {
4746 if ! oDst .IsDir () {
4847 return errors .New (fmt .Sprintf ("%s is not Dir" , dst ))
4948 }
50- // 遍历指定目录下所有文件
51- f , err := ioutil .ReadDir (src )
52- for _ , file := range f {
53- nDst := filepath .Join (dst , file .Name ())
54- nSrc := filepath .Join (src , file .Name ())
55- err = fileMove (nSrc , nDst )
56- if err != nil {
57- return err
58- }
49+ //// 遍历指定目录下所有文件
50+ //f, err := ioutil.ReadDir(src)
51+ //for _, file := range f {
52+ // nDst := filepath.Join(dst, file.Name())
53+ // nSrc := filepath.Join(src, file.Name())
54+ // err = fileMove(nSrc, nDst)
55+ // if err != nil {
56+ // return err
57+ // }
58+ //}
59+ err = fileMove (src , filepath .Join (dst , filepath .Base (dst )))
60+ if err != nil {
61+ return err
5962 }
6063 return err
6164}
0 commit comments