修改DefaultCodes,需要手动赋值

This commit is contained in:
injoyai
2025-03-24 17:01:24 +08:00
parent 1cae60c65e
commit 5e4115d045
3 changed files with 2 additions and 18 deletions

View File

@@ -105,16 +105,6 @@ func DialWith(dial ios.DialFunc, op ...client.Option) (cli *Client, err error) {
go cli.Client.Run()
/*
部分接口需要通过代码信息计算得出
*/
codesOnce.Do(func() {
//初始化代码管理
if DefaultCodes == nil {
DefaultCodes, err = NewCodes(cli, "./codes.db")
}
})
return cli, err
}

View File

@@ -8,17 +8,13 @@ import (
"math"
"os"
"path/filepath"
"sync"
"time"
"xorm.io/core"
"xorm.io/xorm"
)
// 增加单例,部分数据需要通过Codes里面的信息计算
var (
DefaultCodes *Codes
codesOnce sync.Once
)
// DefaultCodes 增加单例,部分数据需要通过Codes里面的信息计算
var DefaultCodes *Codes
func NewCodes(c *Client, filename string) (*Codes, error) {

View File

@@ -27,7 +27,6 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
}
//代码
DefaultCodes = &Codes{}
codesClient, err := cfg.Dial(op...)
if err != nil {
return nil, err
@@ -37,7 +36,6 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
if err != nil {
return nil, err
}
DefaultCodes = codes
//连接池
p, err := NewPool(func() (*Client, error) {