测试demo调整

This commit is contained in:
hoteas 2021-05-22 04:52:03 +08:00
parent 91dc207a78
commit babf6595ee
4 changed files with 17 additions and 16 deletions

View File

@ -1,8 +1,9 @@
package main
import (
"code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/tools/db"
"../../hotime"
"../tools/db"
"database/sql"
"fmt"
//"go.hoteas.com/hotime/cache"
"golang.org/x/net/websocket"
@ -51,15 +52,15 @@ func main() {
appIns.SetCache(hotime.CacheIns(&hotime.CacheMemory{}))
//快捷模式
//appIns.SetDefault(func(err ...*hotime.Error) *sql.DB {
// query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
// "@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
// DB, e := sql.Open("mysql", query)
// if e != nil && len(err) != 0 {
// err[0].SetError(e)
// }
// return DB
//})
appIns.SetDefault(func(err ...*hotime.Error) *sql.DB {
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
"@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
DB, e := sql.Open("mysql", query)
if e != nil && len(err) != 0 {
err[0].SetError(e)
}
return DB
})
appIns.Run(hotime.Router{
"app": hotime.Proj{

View File

@ -1,9 +1,9 @@
package db
import (
"code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/tools/mysql"
"code.hoteas.com/golang/hotime/tools/sqlite"
"../../../hotime"
"../mysql"
"../sqlite"
"strings"
)

View File

@ -1,7 +1,7 @@
package mysql
import (
"code.hoteas.com/golang/hotime"
"../../../hotime"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)

View File

@ -1,7 +1,7 @@
package sqlite
import (
"code.hoteas.com/golang/hotime"
"../../../hotime"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)