Using github.com/sendgrid/sendgrid-go v3.14.0, it appears that Client is not safe for concurrent use.
I was running a service with the race detector enabled, and it detected a data race at:
github.com/sendgrid/sendgrid-go.(*Client).SendWithContext()
/vendor/github.com/sendgrid/sendgrid-go/base_interface.go:65 +0x8c
The problem is (at least) this line:
cl.Body = mail.GetRequestBody(email)
If the client is called concurrently, there is a data race in writing the email parameter to the Body field.
Ideally, the assignment should either be protected by a mutex, or even better, the parameter should not be assigned to any field.
Otherwise, it would be great if you could document that the client is not safe for concurrent use.
Using
github.com/sendgrid/sendgrid-go v3.14.0, it appears thatClientis not safe for concurrent use.I was running a service with the race detector enabled, and it detected a data race at:
The problem is (at least) this line:
If the client is called concurrently, there is a data race in writing the email parameter to the Body field.
Ideally, the assignment should either be protected by a mutex, or even better, the parameter should not be assigned to any field.
Otherwise, it would be great if you could document that the client is not safe for concurrent use.