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