Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 26 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os"
"regexp"
"strings"
"sync"

"github.com/google/go-github/v28/github"
"github.com/sirkon/goproxy/gomod"
Expand Down Expand Up @@ -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!")
}

Expand Down