mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
修改DefaultCodes,需要手动赋值
This commit is contained in:
10
client.go
10
client.go
@@ -105,16 +105,6 @@ func DialWith(dial ios.DialFunc, op ...client.Option) (cli *Client, err error) {
|
|||||||
|
|
||||||
go cli.Client.Run()
|
go cli.Client.Run()
|
||||||
|
|
||||||
/*
|
|
||||||
部分接口需要通过代码信息计算得出
|
|
||||||
*/
|
|
||||||
codesOnce.Do(func() {
|
|
||||||
//初始化代码管理
|
|
||||||
if DefaultCodes == nil {
|
|
||||||
DefaultCodes, err = NewCodes(cli, "./codes.db")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return cli, err
|
return cli, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
codes.go
8
codes.go
@@ -8,17 +8,13 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
"xorm.io/core"
|
"xorm.io/core"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 增加单例,部分数据需要通过Codes里面的信息计算
|
// DefaultCodes 增加单例,部分数据需要通过Codes里面的信息计算
|
||||||
var (
|
var DefaultCodes *Codes
|
||||||
DefaultCodes *Codes
|
|
||||||
codesOnce sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCodes(c *Client, filename string) (*Codes, error) {
|
func NewCodes(c *Client, filename string) (*Codes, error) {
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//代码
|
//代码
|
||||||
DefaultCodes = &Codes{}
|
|
||||||
codesClient, err := cfg.Dial(op...)
|
codesClient, err := cfg.Dial(op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -37,7 +36,6 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
DefaultCodes = codes
|
|
||||||
|
|
||||||
//连接池
|
//连接池
|
||||||
p, err := NewPool(func() (*Client, error) {
|
p, err := NewPool(func() (*Client, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user