forked from golang/hotime
测试demo调整
This commit is contained in:
parent
91dc207a78
commit
babf6595ee
@ -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{
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"code.hoteas.com/golang/hotime"
|
||||
"../../../hotime"
|
||||
"database/sql"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"code.hoteas.com/golang/hotime"
|
||||
"../../../hotime"
|
||||
"database/sql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user