优化代码

This commit is contained in:
hoteas 2021-06-06 02:27:22 +08:00
parent 79453d4d2a
commit 4038598470
3 changed files with 7 additions and 9 deletions

View File

@ -1,7 +1,6 @@
package common package common
import ( import (
"bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"math" "math"
@ -258,11 +257,10 @@ func ObjToStr(obj interface{}) string {
case float64: case float64:
str = strconv.FormatFloat(obj.(float64), 'f', -1, 64) str = strconv.FormatFloat(obj.(float64), 'f', -1, 64)
default: default:
strbte, err := json.Marshal(obj) strbte, err := json.MarshalIndent(obj, "", "\t")
var configByte bytes.Buffer
err = json.Indent(&configByte, strbte, "", "\t")
if err == nil { if err == nil {
str = configByte.String() str = string(strbte)
} }
} }

View File

@ -11,8 +11,8 @@
}, },
"db": { "db": {
"mysql": { "mysql": {
"host": "cloud.hoteas.com", "host": "192.168.6.250",
"name": "ljf", "name": "reg_gqt",
"password": "root", "password": "root",
"port": "3306", "port": "3306",
"prefix": "", "prefix": "",

View File

@ -2,7 +2,7 @@ package main
import ( import (
"../../hotime" "../../hotime"
//"./admin" "./admin"
"errors" "errors"
"fmt" "fmt"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
@ -58,7 +58,7 @@ func main() {
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db))) //fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
appIns.Run(hotime.Router{ appIns.Run(hotime.Router{
//"admin": admin.Project, "admin": admin.Project,
"app": hotime.Proj{ "app": hotime.Proj{
"index": hotime.Ctr{ "index": hotime.Ctr{
"test": func(this *hotime.Context) { "test": func(this *hotime.Context) {