Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions docs/tasks/grpc/server/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,27 @@ ListenOn: 127.0.0.1:8080
<TabItem value="server.go" label="server.go" default>

```go
package main

import (
"context"
"helloworld/greet"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project name is demo, not helloworld


"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)

func main() {
func main() {
var serverConf zrpc.RpcServerConf
conf.MustLoad("etc/greet-server.yaml", &serverConf)
s := zrpc.MustNewServer(serverConf, func(server *grpc.Server) {
greet.RegisterGreetServer(server, &exampleServer{})
s := zrpc.MustNewServer(serverConf, func(s *grpc.Server) {
greet.RegisterGreetServer(s, &exampleServer{})
})

defer s.Stop()
s.Start()
}
}

type exampleServer struct {
greet.UnimplementedGreetServer
Expand All @@ -88,4 +97,4 @@ func (e *exampleServer) Ping(ctx context.Context, request *greet.Request) (*gree

- <a href="/docs/tutorials/cli/rpc" target="_blank"> 《goctl rpc 代码生成》 </a>
- <a href="/docs/tutorials/grpc/client/configuration" target="_blank"> 《rpc 客户端配置》 </a>
- <a href="/docs/tutorials/grpc/client/conn" target="_blank"> 《rpc 服务连接》 </a>
- <a href="/docs/tutorials/grpc/client/conn" target="_blank"> 《rpc 服务连接》 </a>