File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 99)
1010
1111func main () {
12- concurrency := flag .Int ("c" , 2 , "concurrency" )
12+ concurrency := flag .Uint ("c" , 2 , "concurrency" )
1313 outputDir := flag .String ("o" , "./" , "output directory" )
1414
1515 flag .Parse ()
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
1414)
1515
1616type Option struct {
17- Concurrency int
17+ Concurrency uint
1818 URL string
1919 OutputDir string
2020 ContentLength int64
@@ -86,10 +86,17 @@ func (o *Option) contentLength() error {
8686func (o * Option ) divide () {
8787 var units []Unit
8888
89- //TODO: if o.ContentLength < int64(o.Concurrency)
89+ if o .Concurrency == 0 {
90+ o .Concurrency = 1
91+ }
92+
93+ if o .ContentLength < int64 (o .Concurrency ) {
94+ o .Concurrency = uint (o .ContentLength )
95+ }
96+
9097 sbyte := o .ContentLength / int64 (o .Concurrency )
9198
92- for i := 0 ; i < o .Concurrency ; i ++ {
99+ for i := 0 ; i < int ( o .Concurrency ) ; i ++ {
93100 units = append (units , Unit {
94101 RangeStart : int64 (i ) * sbyte ,
95102 RangeEnd : int64 ((i + 1 ))* sbyte - 1 ,
You can’t perform that action at this time.
0 commit comments