From 40385984700495f9e988bf5816d84da9abe3334e Mon Sep 17 00:00:00 2001 From: hoteas <925970985@qq.com> Date: Sun, 6 Jun 2021 02:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/objtoobj.go | 8 +++----- example/config/config.json | 4 ++-- example/main.go | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/common/objtoobj.go b/common/objtoobj.go index 1a8fbd9..e9ce000 100644 --- a/common/objtoobj.go +++ b/common/objtoobj.go @@ -1,7 +1,6 @@ package common import ( - "bytes" "encoding/json" "errors" "math" @@ -258,11 +257,10 @@ func ObjToStr(obj interface{}) string { case float64: str = strconv.FormatFloat(obj.(float64), 'f', -1, 64) default: - strbte, err := json.Marshal(obj) - var configByte bytes.Buffer - err = json.Indent(&configByte, strbte, "", "\t") + strbte, err := json.MarshalIndent(obj, "", "\t") + if err == nil { - str = configByte.String() + str = string(strbte) } } diff --git a/example/config/config.json b/example/config/config.json index 3953905..3415642 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -11,8 +11,8 @@ }, "db": { "mysql": { - "host": "cloud.hoteas.com", - "name": "ljf", + "host": "192.168.6.250", + "name": "reg_gqt", "password": "root", "port": "3306", "prefix": "", diff --git a/example/main.go b/example/main.go index 0db18ce..885be50 100644 --- a/example/main.go +++ b/example/main.go @@ -2,7 +2,7 @@ package main import ( "../../hotime" - //"./admin" + "./admin" "errors" "fmt" "golang.org/x/net/websocket" @@ -58,7 +58,7 @@ func main() { //fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db))) appIns.Run(hotime.Router{ - //"admin": admin.Project, + "admin": admin.Project, "app": hotime.Proj{ "index": hotime.Ctr{ "test": func(this *hotime.Context) {