Skip to content

Commit

Permalink
Fixed example_test.go
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Bergevin <josephbergevin@gmail.com>
Signed-off-by: Adolfo García Veytia (Puerco) <adolfo.garcia@uservers.net>
  • Loading branch information
puerco and josephbergevin committed Jul 23, 2024
1 parent f66ecdb commit e094420
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions throttler/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "fmt"

type httpPkg struct{}

func (httpPkg) Get(url string) {}
func (httpPkg) Get(url string) error { return nil }

var http httpPkg

Expand All @@ -25,7 +25,7 @@ func ExampleThrottler() {
"http://www.somestupidname.com/",
}
// Create a new Throttler that will get 2 urls at a time
t := throttler.New(2, len(urls))
t := New(2, len(urls))
for _, url := range urls {
// Launch a goroutine to fetch the URL.
go func(url string) {
Expand All @@ -39,6 +39,9 @@ func ExampleThrottler() {
// Returning the total number of goroutines that have errored
// lets you choose to break out of the loop without starting any more
errorCount := t.Throttle()
if errorCount > 0 {
break
}
}
}

Expand Down

0 comments on commit e094420

Please sign in to comment.