File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -27,5 +27,9 @@ func main() {
27
27
28
28
option .URL = urls [0 ]
29
29
fmt .Println (option )
30
- rget .Run (option )
30
+ err := rget .Run (option )
31
+ if err != nil {
32
+ fmt .Fprintf (os .Stderr , "err: %s" , err )
33
+ os .Exit (1 )
34
+ }
31
35
}
Original file line number Diff line number Diff line change @@ -38,32 +38,33 @@ func (u *Unit) Write(data []byte) (int, error) {
38
38
39
39
type Units []Unit
40
40
41
- func Run (option Option ) {
41
+ func Run (option Option ) error {
42
42
fmt .Printf ("%+v\n " , option )
43
43
err := option .checkingHeaders ()
44
44
if err != nil {
45
- fmt .Errorf ("%s" , err )
45
+ return fmt .Errorf ("%s" , err )
46
46
}
47
47
48
48
option .divide ()
49
49
50
50
tmpDir , err := ioutil .TempDir ("" , "rget" )
51
51
if err != nil {
52
- fmt .Errorf ("%s" , err )
52
+ return fmt .Errorf ("%s" , err )
53
53
}
54
54
defer os .RemoveAll (tmpDir )
55
55
fmt .Println (tmpDir )
56
56
57
57
err = option .parallelDownload (tmpDir )
58
58
if err != nil {
59
- fmt .Errorf ("%s" , err )
59
+ return fmt .Errorf ("%s" , err )
60
60
}
61
61
62
62
err = option .combine (tmpDir )
63
63
if err != nil {
64
- fmt .Errorf ("%s" , err )
64
+ return fmt .Errorf ("%s" , err )
65
65
}
66
66
67
+ return nil
67
68
}
68
69
69
70
func (o * Option ) checkingHeaders () error {
You can’t perform that action at this time.
0 commit comments