diff --git a/examples/go.mod b/examples/go.mod index 7ca6544bf..2383efd6c 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -7,7 +7,7 @@ require ( github.com/gin-gonic/gin v1.6.3 github.com/go-kratos/consul v0.0.0-20210311161349-cfb0345e820d github.com/go-kratos/etcd v0.0.0-20210311152824-df5743ff1a11 - github.com/go-kratos/kratos/v2 v2.0.0-20210311152607-a4409adf164e + github.com/go-kratos/kratos/v2 v2.0.0-20210315090606-74272546caa6 github.com/go-playground/validator/v10 v10.4.1 // indirect github.com/go-redis/redis/extra/redisotel v0.2.0 github.com/go-redis/redis/v8 v8.6.0 diff --git a/examples/go.sum b/examples/go.sum index 6bf8609c9..6371b9940 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -124,6 +124,8 @@ github.com/go-kratos/etcd v0.0.0-20210311152824-df5743ff1a11 h1:yN0kNvtSmSmTznbv github.com/go-kratos/etcd v0.0.0-20210311152824-df5743ff1a11/go.mod h1:+1nilFyiWLlYpAWliKnbFhIax79n4l0mOTJhyNw5EEw= github.com/go-kratos/kratos/v2 v2.0.0-20210311152607-a4409adf164e h1:x/1thr6sE8fn09HekGNBdBX6PH9T6iacfJor0sDAZ6g= github.com/go-kratos/kratos/v2 v2.0.0-20210311152607-a4409adf164e/go.mod h1:oLvFyDBJkkWN8TPqb+NmpvRrSy9uM/K+XQubVRc11a8= +github.com/go-kratos/kratos/v2 v2.0.0-20210315090606-74272546caa6 h1:iaZamLO1uUf5NBWXZ1WxP12baWhXNySwW3gUDtCkl+4= +github.com/go-kratos/kratos/v2 v2.0.0-20210315090606-74272546caa6/go.mod h1:oLvFyDBJkkWN8TPqb+NmpvRrSy9uM/K+XQubVRc11a8= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= diff --git a/examples/gin/main.go b/examples/http/gin/main.go similarity index 76% rename from examples/gin/main.go rename to examples/http/gin/main.go index 856b77eed..829279d2c 100644 --- a/examples/gin/main.go +++ b/examples/http/gin/main.go @@ -5,7 +5,7 @@ import ( "github.com/gin-gonic/gin" "github.com/go-kratos/kratos/v2" - transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/go-kratos/kratos/v2/transport/http" ) func main() { @@ -13,7 +13,7 @@ func main() { router.GET("/home", func(ctx *gin.Context) { ctx.String(200, "Hello Gin!") }) - httpSrv := transhttp.NewServer(transhttp.Address(":8000")) + httpSrv := http.NewServer(http.Address(":8000")) httpSrv.HandlePrefix("/", router) app := kratos.New( diff --git a/examples/mux/main.go b/examples/http/mux/main.go similarity index 100% rename from examples/mux/main.go rename to examples/http/mux/main.go diff --git a/examples/registry/consul/client/main.go b/examples/registry/consul/client/main.go index f58dfbf13..df9f70cda 100644 --- a/examples/registry/consul/client/main.go +++ b/examples/registry/consul/client/main.go @@ -5,8 +5,8 @@ import ( "log" "github.com/go-kratos/consul/registry" - pb "github.com/go-kratos/kratos/examples/helloworld/helloworld" - transgrpc "github.com/go-kratos/kratos/v2/transport/grpc" + "github.com/go-kratos/kratos/examples/helloworld/helloworld" + "github.com/go-kratos/kratos/v2/transport/grpc" "github.com/hashicorp/consul/api" ) @@ -16,16 +16,16 @@ func main() { panic(err) } r := registry.New(cli) - conn, err := transgrpc.DialInsecure( + conn, err := grpc.DialInsecure( context.Background(), - transgrpc.WithEndpoint("discovery://d/helloworld"), - transgrpc.WithDiscovery(r), + grpc.WithEndpoint("discovery:///helloworld"), + grpc.WithDiscovery(r), ) if err != nil { log.Fatal(err) } - client := pb.NewGreeterClient(conn) - reply, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "kratos"}) + client := helloworld.NewGreeterClient(conn) + reply, err := client.SayHello(context.Background(), &helloworld.HelloRequest{Name: "kratos"}) if err != nil { log.Fatal(err) } diff --git a/examples/registry/etcd/client/main.go b/examples/registry/etcd/client/main.go index b09cdb068..d8da9b986 100644 --- a/examples/registry/etcd/client/main.go +++ b/examples/registry/etcd/client/main.go @@ -5,8 +5,8 @@ import ( "log" "github.com/go-kratos/etcd/registry" - pb "github.com/go-kratos/kratos/examples/helloworld/helloworld" - transgrpc "github.com/go-kratos/kratos/v2/transport/grpc" + "github.com/go-kratos/kratos/examples/helloworld/helloworld" + "github.com/go-kratos/kratos/v2/transport/grpc" clientv3 "go.etcd.io/etcd/client/v3" ) @@ -18,16 +18,16 @@ func main() { panic(err) } r := registry.New(cli) - conn, err := transgrpc.DialInsecure( + conn, err := grpc.DialInsecure( context.Background(), - transgrpc.WithEndpoint("discovery://d/helloworld"), - transgrpc.WithDiscovery(r), + grpc.WithEndpoint("discovery:///helloworld"), + grpc.WithDiscovery(r), ) if err != nil { log.Fatal(err) } - client := pb.NewGreeterClient(conn) - reply, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "kratos"}) + client := helloworld.NewGreeterClient(conn) + reply, err := client.SayHello(context.Background(), &helloworld.HelloRequest{Name: "kratos"}) if err != nil { log.Fatal(err) } diff --git a/examples/registry/etcd/server/main.go b/examples/registry/etcd/server/main.go index 8948cad6d..f684d5b70 100644 --- a/examples/registry/etcd/server/main.go +++ b/examples/registry/etcd/server/main.go @@ -9,7 +9,7 @@ import ( pb "github.com/go-kratos/kratos/examples/helloworld/helloworld" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/transport/grpc" - clientv3 "go.etcd.io/etcd/client/v3" + etcd "go.etcd.io/etcd/client/v3" ) // server is used to implement helloworld.GreeterServer. @@ -30,11 +30,11 @@ func main() { s := &server{} pb.RegisterGreeterServer(grpcSrv, s) - cli, err := clientv3.New(clientv3.Config{ + cli, err := etcd.New(etcd.Config{ Endpoints: []string{"127.0.0.1:2379"}, }) if err != nil { - panic(err) + log.Fatal(err) } r := registry.New(cli) app := kratos.New(