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