From d6371c728933b127ad27228ade274d42c9a3b232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=BC=BA?= Date: Thu, 13 Apr 2023 14:23:46 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20panic=EF=BC=8C?= =?UTF-8?q?=E8=BD=AC=E7=A7=BB=20cache=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=88=B0=20Wechat=20=E7=BB=93=E6=9E=84=E4=BD=93=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=B8=8B=EF=BC=9B=E5=9C=A8=E4=BD=BF=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=8F=AA=E8=AE=BE=E7=BD=AE=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=20cache=20=E5=90=8C=E6=97=B6=E9=81=BF=E5=85=8D=20panic=20?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=20(#668)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openplatform/openplatform.go | 3 --- wechat.go | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) 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) }