package main import ( "bytes" "crypto/md5" "encoding/json" "fmt" "github.com/golang/glog" "io" "io/ioutil" "math" "mime/multipart" "net/http" "os" "strconv" "strings" "sync" "time" "unsafe" ) const CONFIG_PATH = "./config.conf" func main() { var wg sync.WaitGroup //读取配置文件 confs := Json2Map(CONFIG_PATH) FilePath := confs["FilePath"] //读取指定目录中的所有文件和子目录 files, err := ioutil.ReadDir(FilePath) if err != nil { glog.Error("读取指定目录中的所有文件和子目录失败;",FilePath, err) } //循环上传 for k := range files { wg.Add(1) tmp := files[k] go func() { defer wg.Done() UploadSigleFile(tmp, confs) }() //go func (file os.FileInfo){ // UploadSigleFile(file, confs) //}(file) //UploadSigleFile(file, confs) } wg.Wait() //time.Sleep(1000000 * time.Millisec