Skip to content

Commit

Permalink
fix: Synchronize goroutines accessing shared var
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek committed Aug 3, 2020
1 parent f5fd87f commit 7a3380b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

var configPath string
var removed int = 0
var mutex = &sync.Mutex{}

func main() {
parseCmdFlags()
Expand Down Expand Up @@ -47,6 +48,8 @@ func deleteIssueReactions(wg *sync.WaitGroup, client *github.Client, cfg *Config
if err != nil {
fmt.Fprintf(os.Stderr, "[WARN] Could not delete reaction %v\nerror:\n%v", reaction, err)
} else {
mutex.Lock()
defer mutex.Unlock()
removed++
}
}
Expand Down

0 comments on commit 7a3380b

Please sign in to comment.