|
@@ -4,7 +4,6 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"net/url"
|
|
|
- "sync"
|
|
|
"time"
|
|
|
|
|
|
"git.chuangxin1.com/cx/myth"
|
|
@@ -20,15 +19,15 @@ func NewClient(appID, appSecret, token, encodingAESKey string) *Client {
|
|
|
if v, ok := cache.Load(key); ok {
|
|
|
return v.(*Client)
|
|
|
}
|
|
|
- c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey, ReadLock: &sync.Mutex{}}
|
|
|
+ c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey}
|
|
|
cache.Store(key, c)
|
|
|
return c
|
|
|
}
|
|
|
|
|
|
// getToken get token
|
|
|
func (wc *Client) getToken() (token string, err error) {
|
|
|
- wc.ReadLock.Lock()
|
|
|
- defer wc.ReadLock.Unlock()
|
|
|
+ //wc.ReadLock.Lock()
|
|
|
+ //defer wc.ReadLock.Unlock()
|
|
|
now := time.Now().Unix()
|
|
|
if wc.LastTokenTime > 0 {
|
|
|
if now-wc.LastTokenTime < TokenExpires {
|