1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

chore: 移除 panic,转移 cache 初始化到 Wechat 结构体方法下;在使用时可以只设置一次 cache 同时避免 panic 出现 (#668)

This commit is contained in:
牛强
2023-04-13 14:23:46 +08:00
committed by GitHub
parent 07b7dc40fc
commit d6371c7289
2 changed files with 3 additions and 3 deletions

View File

@@ -18,9 +18,6 @@ type OpenPlatform struct {
// NewOpenPlatform new openplatform
func NewOpenPlatform(cfg *config.Config) *OpenPlatform {
if cfg.Cache == nil {
panic("cache 未设置")
}
ctx := &context.Context{
Config: cfg,
}

View File

@@ -68,6 +68,9 @@ func (wc *Wechat) GetPay(cfg *payConfig.Config) *pay.Pay {
// GetOpenPlatform 获取微信开放平台的实例
func (wc *Wechat) GetOpenPlatform(cfg *openConfig.Config) *openplatform.OpenPlatform {
if cfg.Cache == nil {
cfg.Cache = wc.cache
}
return openplatform.NewOpenPlatform(cfg)
}