mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 21:02:25 +08:00
Merge pull request #2 from silenceper/develop
1.golint 命名规范 2.解决go vet 发现的一些隐藏bug
This commit is contained in:
@@ -22,8 +22,8 @@ type Context struct {
|
||||
//accessTokenLock 读写锁 同一个AppID一个
|
||||
accessTokenLock *sync.RWMutex
|
||||
|
||||
//jsapiTicket 读写锁 同一个AppID一个
|
||||
jsApiTicketLock *sync.RWMutex
|
||||
//jsAPITicket 读写锁 同一个AppID一个
|
||||
jsAPITicketLock *sync.RWMutex
|
||||
}
|
||||
|
||||
// Query returns the keyed url query value if it exists
|
||||
@@ -41,11 +41,12 @@ func (ctx *Context) GetQuery(key string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
//SetJsApiTicket 设置jsApiTicket的lock
|
||||
func (ctx *Context) SetJsApiTicketLock(lock *sync.RWMutex) {
|
||||
ctx.jsApiTicketLock = lock
|
||||
//SetJsAPITicketLock 设置jsAPITicket的lock
|
||||
func (ctx *Context) SetJsAPITicketLock(lock *sync.RWMutex) {
|
||||
ctx.jsAPITicketLock = lock
|
||||
}
|
||||
|
||||
func (ctx *Context) GetJsApiTicketLock() *sync.RWMutex {
|
||||
return ctx.jsApiTicketLock
|
||||
//GetJsAPITicketLock 获取jsAPITicket 的lock
|
||||
func (ctx *Context) GetJsAPITicketLock() *sync.RWMutex {
|
||||
return ctx.jsAPITicketLock
|
||||
}
|
||||
|
||||
4
js/js.go
4
js/js.go
@@ -63,8 +63,8 @@ func (js *Js) GetConfig(uri string) (config *Config, err error) {
|
||||
|
||||
//getTicket 获取jsapi_tocket全局缓存
|
||||
func (js *Js) getTicket() (ticketStr string, err error) {
|
||||
js.GetJsApiTicketLock().Lock()
|
||||
defer js.GetJsApiTicketLock().Unlock()
|
||||
js.GetJsAPITicketLock().Lock()
|
||||
defer js.GetJsAPITicketLock().Unlock()
|
||||
|
||||
//先从cache中取
|
||||
jsAPITicketCacheKey := fmt.Sprintf("jsapi_ticket_%s", js.AppID)
|
||||
|
||||
@@ -38,7 +38,7 @@ type Article struct {
|
||||
|
||||
//reqArticles 永久性图文素材请求信息
|
||||
type reqArticles struct {
|
||||
articles []*Article `json:"articles"`
|
||||
Articles []*Article `json:"articles"`
|
||||
}
|
||||
|
||||
//resArticles 永久性图文素材返回结果
|
||||
|
||||
@@ -61,7 +61,7 @@ type ResMenu struct {
|
||||
Button []Button `json:"button"`
|
||||
MenuID int64 `json:"menuid"`
|
||||
} `json:"menu"`
|
||||
conditionalmenu []resConditionalMenu `json:"conditionalmenu"`
|
||||
Conditionalmenu []resConditionalMenu `json:"conditionalmenu"`
|
||||
}
|
||||
|
||||
//ResSelfMenuInfo 自定义菜单配置返回结果
|
||||
|
||||
@@ -80,13 +80,13 @@ type MixMessage struct {
|
||||
URL string `xml:"Url"`
|
||||
|
||||
//事件相关
|
||||
Event string `xml:"Event"`
|
||||
EventKey string `xml:"EventKey"`
|
||||
Ticket string `xml:"Ticket"`
|
||||
Latitude string `xml:"Latitude"`
|
||||
Longitude string `xml:"Longitude"`
|
||||
Precision string `xml:"Precision"`
|
||||
MenuID string `xml:"MenuId"`
|
||||
Event EventType `xml:"Event"`
|
||||
EventKey string `xml:"EventKey"`
|
||||
Ticket string `xml:"Ticket"`
|
||||
Latitude string `xml:"Latitude"`
|
||||
Longitude string `xml:"Longitude"`
|
||||
Precision string `xml:"Precision"`
|
||||
MenuID string `xml:"MenuId"`
|
||||
|
||||
ScanCodeInfo struct {
|
||||
ScanType string `xml:"ScanType"`
|
||||
@@ -109,7 +109,7 @@ type MixMessage struct {
|
||||
|
||||
//EventPic 发图事件推送
|
||||
type EventPic struct {
|
||||
PicMd5Sum string `xml:PicMd5Sum`
|
||||
PicMd5Sum string `xml:"PicMd5Sum"`
|
||||
}
|
||||
|
||||
//EncryptedXMLMsg 安全模式下的消息体
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package util
|
||||
|
||||
//CommonError 微信返回的通用错误json
|
||||
type CommonError struct {
|
||||
ErrCode int64 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
|
||||
@@ -41,7 +41,7 @@ func copyConfigToContext(cfg *Config, context *context.Context) {
|
||||
context.EncodingAESKey = cfg.EncodingAESKey
|
||||
context.Cache = cfg.Cache
|
||||
context.SetAccessTokenLock(new(sync.RWMutex))
|
||||
context.SetJsApiTicketLock(new(sync.RWMutex))
|
||||
context.SetJsAPITicketLock(new(sync.RWMutex))
|
||||
}
|
||||
|
||||
//GetServer 消息管理
|
||||
|
||||
Reference in New Issue
Block a user