diff --git a/openplatform/openplatform.go b/openplatform/openplatform.go index 80fb82e..5c509b9 100644 --- a/openplatform/openplatform.go +++ b/openplatform/openplatform.go @@ -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, } diff --git a/wechat.go b/wechat.go index fc98400..e003dac 100644 --- a/wechat.go +++ b/wechat.go @@ -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) }