diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e3b65..50fdecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [v0.3.1] - 2021-01-04 +### Added +- Concurrently like all repos at once with `goroutine` + ## [v0.3.0] - 2020-04-12 ### Added - Run gothanks using docker diff --git a/main.go b/main.go index 91867b0..21da722 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ import ( "os" "regexp" "strings" + "sync" "github.com/google/go-github/v28/github" "github.com/sirkon/goproxy/gomod" @@ -89,29 +90,35 @@ func main() { } fmt.Print("\nSending your love..\n\n") + var wg sync.WaitGroup for _, dep := range repos { - - if rep, ok := isGithubRepo(dep); ok { - x, _, err := client.Activity.IsStarred(ctx, rep.owner, rep.repo) - if err != nil { - fmt.Println(err) - continue - } - - if x { - fmt.Printf("Repository %s is already starred!\n", rep.path) - continue - } - - fmt.Printf("Sending a star to %s\n", rep.path) - - _, err = client.Activity.Star(ctx, rep.owner, rep.repo) - if err != nil { - fmt.Printf("Could not star %s %s\n", rep.path, err) + wg.Add(1) + go func(dep string, wg *sync.WaitGroup) { + defer wg.Done() + if rep, ok := isGithubRepo(dep); ok { + x, _, err := client.Activity.IsStarred(ctx, rep.owner, rep.repo) + if err != nil { + fmt.Println(err) + return + } + + if x { + fmt.Printf("Repository %s is already starred!\n", rep.path) + return + } + + fmt.Printf("Sending a star to %s\n", rep.path) + + _, err = client.Activity.Star(ctx, rep.owner, rep.repo) + if err != nil { + fmt.Printf("Could not star %s %s\n", rep.path, err) + } } - } + }(dep, &wg) } + wg.Wait() + fmt.Println("\nThank you!") }