From https://godoc.org/net/http:
Clients and Transports are safe for concurrent use by multiple goroutines and for efficiency should only be created once and re-used.
https://godoc.org/github.com/google/go-github/github#Client makes no such claims, which is why I'm unsure if this is a bug or intended behavior.
However, given that it looks and feels a lot like http.Client, I thought it might also support concurrent use by multiple goroutines and for efficiency should only be created once and re-used.
That's not the case. If you look at the source of github.Client.Do:
It writes to c.Rate without any mutexes, which is not safe and will cause data races:
WARNING: DATA RACE
Write by goroutine 93:
github.com/google/go-github/github.(*Client).Do()
.../src/github.com/google/go-github/github/github.go:310 +0x16b
Is that intended, or is this a bug?
If I want to make concurrent calls to GitHub API via multiple goroutines, should I create multiple github.Clients?
From https://godoc.org/net/http:
https://godoc.org/github.com/google/go-github/github#Client makes no such claims, which is why I'm unsure if this is a bug or intended behavior.
However, given that it looks and feels a lot like
http.Client, I thought it might also support concurrent use by multiple goroutines and for efficiency should only be created once and re-used.That's not the case. If you look at the source of
github.Client.Do:It writes to
c.Ratewithout any mutexes, which is not safe and will cause data races:Is that intended, or is this a bug?
If I want to make concurrent calls to GitHub API via multiple goroutines, should I create multiple
github.Clients?