chore(examples): optimize typos of swagger/server (#1862)

status-code-override
kwanhur 3 years ago committed by chenzhihui
parent 6dc826b7ea
commit c3de800938
  1. 10
      examples/swagger/server/main.go

@ -6,7 +6,7 @@ import (
"os" "os"
pb "github.com/go-kratos/kratos/examples/swagger/helloworld" pb "github.com/go-kratos/kratos/examples/swagger/helloworld"
reply "github.com/go-kratos/kratos/examples/swagger/reply" "github.com/go-kratos/kratos/examples/swagger/reply"
"github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/errors"
"github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/log"
@ -28,7 +28,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
if in.Name == "error" { if in.Name == "error" {
return nil, errors.BadRequest("custom_error", fmt.Sprintf("invalid argument %s", in.Name)) return nil, errors.BadRequest("custom_error", fmt.Sprintf("invalid argument %s", in.Name))
} }
@ -40,9 +40,9 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe
} }
func main() { func main() {
logger := log.NewStdLogger(os.Stdout) stdLogger := log.NewStdLogger(os.Stdout)
log := log.NewHelper(logger) logger := log.NewHelper(stdLogger)
s := &server{} s := &server{}
httpSrv := http.NewServer(http.Address(":8000")) httpSrv := http.NewServer(http.Address(":8000"))
@ -62,6 +62,6 @@ func main() {
) )
if err := app.Run(); err != nil { if err := app.Run(); err != nil {
log.Error(err) logger.Error(err)
} }
} }

Loading…
Cancel
Save