代码拉取完成,页面将自动刷新
同步操作将从 andeyalee/lessgo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package lessgo
import (
"encoding/json"
"fmt"
"mime"
"os"
"path/filepath"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
"github.com/lessgo/lessgo/config"
"github.com/lessgo/lessgo/dbservice"
"github.com/lessgo/lessgo/logs"
"github.com/lessgo/lessgo/session"
)
func printInfo() {
fmt.Printf(">%s %s (%s)\n", NAME, VERSION, ADDRESS)
}
func registerMime() error {
for k, v := range mimemaps {
mime.AddExtensionType(k, v)
}
return nil
}
func registerAppConfig() (err error) {
fname := APPCONFIG_FILE
appconf, err := config.NewConfig("ini", fname)
if err == nil {
trySetAppConfig(appconf.(*config.IniConfigContainer))
return appconf.SaveConfigFile(fname)
}
os.MkdirAll(filepath.Dir(fname), 0777)
f, err := os.Create(fname)
if err != nil {
panic(err)
}
f.Close()
appconf, err = config.NewConfig("ini", fname)
defaultAppConfig(appconf.(*config.IniConfigContainer))
return appconf.SaveConfigFile(fname)
}
func registerDBConfig() (err error) {
fname := DBCONFIG_FILE
appconf, err := config.NewConfig("ini", fname)
if err == nil {
trySetDBConfig(appconf.(*config.IniConfigContainer))
return appconf.SaveConfigFile(fname)
}
os.MkdirAll(filepath.Dir(fname), 0777)
f, err := os.Create(fname)
if err != nil {
panic(err)
}
f.Close()
appconf, err = config.NewConfig("ini", fname)
defaultDBConfig(appconf.(*config.IniConfigContainer))
return appconf.SaveConfigFile(fname)
}
func registerRouter() error {
// 从数据读取动态配置
// 与源码配置进行同步
// 创建真实路由
ResetRealRoute()
return nil
}
func registerSession() (err error) {
if !AppConfig.Session.Enable {
return
}
conf := map[string]interface{}{
"cookieName": AppConfig.Session.CookieName,
"gclifetime": AppConfig.Session.GcMaxlifetime,
"providerConfig": filepath.ToSlash(AppConfig.Session.ProviderConfig),
"secure": AppConfig.Listen.EnableHTTPS,
"enableSetCookie": AppConfig.Session.EnableSetCookie,
"domain": AppConfig.Session.Domain,
"cookieLifeTime": AppConfig.Session.CookieLifeTime,
}
confBytes, err := json.Marshal(conf)
if err != nil {
return err
}
sessionConfig := string(confBytes)
GlobalSessions, err = session.NewManager(AppConfig.Session.Provider, sessionConfig)
if err != nil {
return
}
go GlobalSessions.GC()
return
}
func checkHooks(err error) {
if err == nil {
return
}
DefLessgo.Echo.Logger().Fatal("%v", err)
}
func newDBAccess() *dbservice.DBAccess {
access := &dbservice.DBAccess{
List: map[string]*xorm.Engine{},
}
for _, conf := range AppConfig.DBList {
engine, err := xorm.NewEngine(conf.Driver, conf.ConnString)
if err != nil {
logs.Error("%v", err)
continue
}
logger := dbservice.NewILogger(AppConfig.Log.AsyncChan, AppConfig.Log.Level, conf.Name)
engine.SetLogger(logger)
engine.SetMaxOpenConns(conf.MaxOpenConns)
engine.SetMaxIdleConns(conf.MaxIdleConns)
engine.SetDisableGlobalCache(conf.DisableCache)
engine.ShowSQL(conf.ShowSql)
engine.ShowExecTime(conf.ShowExecTime)
if (conf.TableFix == "prefix" || conf.TableFix == "suffix") && len(conf.TableSpace) > 0 {
var impr core.IMapper
if conf.TableSnake {
impr = core.SnakeMapper{}
} else {
impr = core.SameMapper{}
}
if conf.TableFix == "prefix" {
engine.SetTableMapper(core.NewPrefixMapper(impr, conf.TableSpace))
} else {
engine.SetTableMapper(core.NewSuffixMapper(impr, conf.TableSpace))
}
}
if (conf.ColumnFix == "prefix" || conf.ColumnFix == "suffix") && len(conf.ColumnSpace) > 0 {
var impr core.IMapper
if conf.ColumnSnake {
impr = core.SnakeMapper{}
} else {
impr = core.SameMapper{}
}
if conf.ColumnFix == "prefix" {
engine.SetTableMapper(core.NewPrefixMapper(impr, conf.ColumnSpace))
} else {
engine.SetTableMapper(core.NewSuffixMapper(impr, conf.ColumnSpace))
}
}
access.List[conf.Name] = engine
if AppConfig.DefaultDB == conf.Name {
access.Default = engine
}
}
return access
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。