You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CSPAPIToken option can change in unexpected ways. Ideally an option should be immutable once created. Consider this code:
cspOptions := []CSPOption{CSPOrgId("orgId")}
option := CSAPIToken("tokenName", cspOptions...)
sender := NewSender(wavefrontURL, option)
cspOptions[0] = CSPOrgId("aDifferentOrgId")
// Oops, anotherSender will use "aDifferentOrgId" because option changed as a side effect
anotherSender := NewSender(wavefrontURL, option)
Solution, the CSPAPIToken() function should take a defensive copy of the slice of CSPOptions passed in. Then it should use that defensive copy in the returned function. This would be enough:
The CSPAPIToken option can change in unexpected ways. Ideally an option should be immutable once created. Consider this code:
Solution, the CSPAPIToken() function should take a defensive copy of the slice of CSPOptions passed in. Then it should use that defensive copy in the returned function. This would be enough:
The text was updated successfully, but these errors were encountered: