package main import ( "bytes" "flag" "fmt" "github.com/astaxie/beego/httplib" "github.com/sjqzhang/goutil" "io/ioutil" "os" "path/filepath" "sync" "time" ) var url *string var dir *string var worker *int var queue chan string var filesize *int var filecount *int var retry *int var gen *bool var done chan bool=make(chan bool,1) var wg sync.WaitGroup=sync.WaitGroup{} var util goutil.Common func init() { util=goutil.Common{} } func getDir(dir string) []string { var ( paths []string ) filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if !info.IsDir() { paths = append(paths, path) } return nil }) return paths } func sendFile() { for { filePath:= <-queue req := httplib.Post(*url) req.PostFile("file", filePath) //注意不是全路径 req.Param("output", "text") req.Param("scene", "") req.Param("path", "") req.Retries(*retry) if s,err:=req.String();err!=nil { fmt.Println(err,filePath) } else { fmt.Println(s,filePath) } wg.Done() } } func genMemFile() []byte { bufstr:=bytes.Buffer{} bufstr.Grow(*filesize) for i:=0;i<*filesize;i++ { bufstr.Write([]byte("a")) } return bufstr.Bytes() } func genFile() { j:=0 buf:=genMemFile() for i:=0;i<*filecount;i++ { if i%1000==0 { j=i os.Mkdir(fmt.Sprintf("%d",i),0666) } uuid:=util.GetUUID() for k:=0;k