Skip to content

Commit

Permalink
添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
zxysilent committed Dec 12, 2018
1 parent 181e947 commit 9bba092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions model/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var DB *xorm.Engine
var Conf config

func init() {
// 读取配置文件
conf, err := os.Open("./conf.json")
if err != nil {
log.Fatalln("配置文件读取失败", err.Error())
Expand All @@ -27,6 +28,7 @@ func init() {
if err != nil {
log.Fatalln("配置文件无效", err.Error())
}
// 初始化数据库操作的 Xorm
DB, err = xorm.NewEngine("mysql", Conf.Conn)
if err != nil {
log.Fatalln("数据库连接失败", err.Error())
Expand All @@ -36,7 +38,9 @@ func init() {
if err = DB.Ping(); err != nil {
log.Fatalln("数据库不能正常工作", err.Error())
}
// 更加开发环境是否显示sql执行的语句
DB.ShowSQL(Conf.Debug)
// 设置xorm缓存
cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
DB.SetDefaultCacher(cacher)
// DB.Logger().SetLevel(0)
Expand Down
1 change: 1 addition & 0 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"
)

// 性能测试
func BenchmarkRandStr6(b *testing.B) {
for i := 0; i < b.N; i++ {
RandStr(16)
Expand Down

0 comments on commit 9bba092

Please sign in to comment.