1 Star 0 Fork 0

Stefan/xgameCommon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ExternalGWConfig.go 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
Stefan 提交于 2020-05-11 20:14 . fix import package.
package serverConfig
import (
"github.com/Peakchen/xcommon/Config"
"fmt"
"path/filepath"
"strconv"
)
/*
export from ExternalGWConfig.json by tool.
*/
type TExternalgwconfigBase struct {
Id int32 `json:"id"`
Listenaddr string `json:"ListenAddr"`
Pprofaddr string `json:"PProfAddr"`
Name string
}
type TExternalgwconfigConfig struct {
data *TExternalgwconfigBase
}
type tArrExternalgwconfig []*TExternalgwconfigBase
var (
GExternalgwconfigConfig *TExternalgwconfigConfig = &TExternalgwconfigConfig{}
cstExternalDef = "ExternalGateway"
)
func init() {
//loadExternalgwConfig()
}
func loadExternalgwConfig() {
var (
ExternalGWpath string
)
if len(SvrPath) == 0 {
ExternalGWpath = getserverpath()
}
ExternalGWpath = filepath.Join(SvrPath, "ExternalGWConfig.json")
Config.ParseJson2Cache(GExternalgwconfigConfig, &tArrExternalgwconfig{}, ExternalGWpath)
}
func (this *TExternalgwconfigConfig) ComfireAct(data interface{}) (errlist []string) {
cfg := data.(*tArrExternalgwconfig)
errlist = []string{}
for _, item := range *cfg {
if len(item.Listenaddr) == 0 {
errlist = append(errlist, fmt.Sprintf("ExternalGWConfig listeraddr invalid, id: %v.", item.Id))
}
if len(item.Pprofaddr) == 0 {
errlist = append(errlist, fmt.Sprintf("ExternalGWConfig Pprofaddr invalid, id: %v.", item.Id))
}
}
return
}
func (this *TExternalgwconfigConfig) DataRWAct(data interface{}) (errlist []string) {
cfg := data.(*tArrExternalgwconfig)
this.data = &TExternalgwconfigBase{}
for _, item := range *cfg {
item.Name = cstExternalDef + "_" + strconv.Itoa(int(item.Id))
this.data = item
break
}
return
}
func (this *TExternalgwconfigConfig) Get() *TExternalgwconfigBase {
return this.data
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/emmm_admin/xgameCommon.git
git@gitee.com:emmm_admin/xgameCommon.git
emmm_admin
xgameCommon
xgameCommon
v0.0.3

搜索帮助