-
-
Save emretanriverdi/4d49510622cf9c362a60996d5d49357c to your computer and use it in GitHub Desktop.
anonymous-function-goroutine.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func upsertAllUsersToPostgres(users []User) { | |
var wg sync.WaitGroup | |
wg.Add(len(users)) | |
for _, user := range users { | |
go func(user User, wg *sync.WaitGroup) { | |
repository.UpsertToPostgres(user) | |
wg.Done() | |
}(user, &wg) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment