diff --git a/global.go b/global.go index 75521d4..2d34590 100644 --- a/global.go +++ b/global.go @@ -115,7 +115,8 @@ var ( ) // ALL 跟search函数搭配 -// friends.Search(openwechat.ALL, ) +// +// friends.Search(openwechat.ALL, ) const ALL = 0 // 性别 @@ -137,11 +138,11 @@ const ( const TimeFormat = "Mon Jan 02 2006 15:04:05 GMT+0800 (中国标准时间)" -var imageType = map[string]bool{ - "bmp": true, - "png": true, - "jpeg": true, - "jpg": true, +var imageType = map[string]struct{}{ + "bmp": {}, + "png": {}, + "jpeg": {}, + "jpg": {}, } var videoType = "mp4" diff --git a/parser.go b/parser.go index fe86f92..4c01a6b 100644 --- a/parser.go +++ b/parser.go @@ -81,9 +81,10 @@ const ( // 微信匹配文件类型策略 func getMessageType(filename string) string { ext := getFileExt(filename) - if imageType[ext] { + if _, ok := imageType[ext]; ok { return pic - } else if ext == videoType { + } + if ext == videoType { return video } return doc