Use t.Sub(time.Now()) because time.Until isn't available until go 1.8

This commit is contained in:
Bryce Kahle 2017-07-06 19:08:37 -04:00
parent d06b0102ce
commit a4e4a4476c

View File

@ -127,7 +127,7 @@ func (c *Client) Send(req *http.Request, v interface{}) error {
// client.Token will be updated when changed
func (c *Client) SendWithAuth(req *http.Request, v interface{}) error {
if c.Token != nil {
if !c.tokenExpiresAt.IsZero() && time.Until(c.tokenExpiresAt) < RequestNewTokenBeforeExpiresIn {
if !c.tokenExpiresAt.IsZero() && c.tokenExpiresAt.Sub(time.Now()) < RequestNewTokenBeforeExpiresIn {
// c.Token will be updated in GetAccessToken call
if _, err := c.GetAccessToken(); err != nil {
return err