Skip to content

Commit df83b1b

Browse files
committed
refactor(js): correct initialization of Config in GetConfig method
- Removed redundant initialization of the Config variable and ensured it is instantiated correctly before use. - This change improves code clarity and maintains the intended functionality of the GetConfig method.
1 parent 0828c2c commit df83b1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

officialaccount/js/js.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func (js *Js) SetJsTicketHandle(ticketHandle credential.JsTicketHandle) {
3939
// GetConfig 获取jssdk需要的配置参数
4040
// uri 为当前网页地址
4141
func (js *Js) GetConfig(uri string) (config *Config, err error) {
42-
config = new(Config)
4342
var accessToken string
4443
accessToken, err = js.GetAccessToken()
4544
if err != nil {
@@ -54,6 +53,7 @@ func (js *Js) GetConfig(uri string) (config *Config, err error) {
5453
timestamp := util.GetCurrTS()
5554
str := fmt.Sprintf("jsapi_ticket=%s&noncestr=%s&timestamp=%d&url=%s", ticketStr, nonceStr, timestamp, uri)
5655
sigStr := util.Signature(str)
56+
config = new(Config)
5757
config.AppID = js.AppID
5858
config.NonceStr = nonceStr
5959
config.Timestamp = timestamp

0 commit comments

Comments
 (0)