This is an automated email from the ASF dual-hosted git repository. joezou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
commit f71bec19c52e806b603205347098f43c566cd292 Author: shen <zhang...@cmiot.chinamobile.com> AuthorDate: Thu Oct 29 14:51:25 2020 +0800 code optimization --- registry/servicediscovery/consul/go-client/app/client.go | 11 +++++++---- registry/servicediscovery/consul/go-server/app/user.go | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/registry/servicediscovery/consul/go-client/app/client.go b/registry/servicediscovery/consul/go-client/app/client.go index 5d3f04b..08e329d 100644 --- a/registry/servicediscovery/consul/go-client/app/client.go +++ b/registry/servicediscovery/consul/go-client/app/client.go @@ -27,8 +27,6 @@ import ( ) import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/common/logger" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" @@ -45,6 +43,11 @@ import ( _ "github.com/apache/dubbo-go/metadata/service/remote" _ "github.com/apache/dubbo-go/registry/consul" _ "github.com/apache/dubbo-go/registry/servicediscovery" + gxlog "github.com/dubbogo/gost/log" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" ) var ( @@ -59,14 +62,14 @@ func main() { config.Load() time.Sleep(3e9) - fmt.Printf("\033[32;40m" + "\n\n\nstart to test dubbo" + "\033[0m\n") + gxlog.CInfo("\n\n\nstart to test dubbo\n") user := &User{} for i := 0; i < 5; i++ { err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) if err != nil { panic(err) } - fmt.Printf("\033[32;40m"+"response result: %v\n"+"\033[0m\n", user) + gxlog.CInfo("response result: %v\n", user) } initSignal() } diff --git a/registry/servicediscovery/consul/go-server/app/user.go b/registry/servicediscovery/consul/go-server/app/user.go index 8dea8a2..2132357 100644 --- a/registry/servicediscovery/consul/go-server/app/user.go +++ b/registry/servicediscovery/consul/go-server/app/user.go @@ -19,7 +19,6 @@ package main import ( "context" - "fmt" "time" ) @@ -28,6 +27,10 @@ import ( "github.com/apache/dubbo-go/config" ) +import ( + gxlog "github.com/dubbogo/gost/log" +) + func init() { config.SetProviderService(new(UserProvider)) // ------for hessian2------ @@ -45,9 +48,9 @@ type UserProvider struct { } func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) { - fmt.Printf("\033[32;40m"+"req:%#v"+"\033[0m\n", req) + gxlog.CInfo("req: %v\n", req) rsp := User{"A001", "Alex Stocks", 18, time.Now()} - fmt.Printf("\033[32;40m"+"rsp:%#v"+"\033[0m\n", rsp) + gxlog.CInfo("rsp: %v\n", rsp) return &rsp, nil }