From 34bcbd9571a1c18aae28b39ed0d5e045c49ebe07 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Thu, 4 May 2023 10:05:32 +0800 Subject: [PATCH] fix: gopeed cli negative WaitGroup counter error (#110) --- _examples/basic/main.go | 5 ++++- cmd/gopeed/main.go | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/_examples/basic/main.go b/_examples/basic/main.go index 63c106ce..0fbe4315 100644 --- a/_examples/basic/main.go +++ b/_examples/basic/main.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/GopeedLab/gopeed/pkg/base" "github.com/GopeedLab/gopeed/pkg/download" + "github.com/GopeedLab/gopeed/pkg/protocol/http" ) func main() { @@ -16,7 +17,9 @@ func main() { } }). Create(&base.Options{ - Connections: 8, + Extra: http.OptsExtra{ + Connections: 8, + }, }) if err != nil { panic(err) diff --git a/cmd/gopeed/main.go b/cmd/gopeed/main.go index 251c89f3..e9d55d38 100644 --- a/cmd/gopeed/main.go +++ b/cmd/gopeed/main.go @@ -13,9 +13,17 @@ import ( const progressWidth = 20 func main() { - args := parse() + //args := parse() + var dir = "./" + var connections = 8 + args := &args{ + url: "https://sel-kor-ping.vultr.com/vultr.com.100MB.bin", + dir: &dir, + connections: &connections, + } var wg sync.WaitGroup + wg.Add(1) _, err := download.Boot(). URL(args.url). Listener(func(event *download.Event) { @@ -46,7 +54,6 @@ func main() { if err != nil { panic(err) } - wg.Add(1) wg.Wait() }