--- url: "https://grpc.io/docs/languages/go/quickstart" titulek: "Quick start | Go | gRPC" h1: "Quick start" popis: "This guide gets you started with gRPC in Go with a simple working example." jazyk: "en" kanonicka: "https://grpc.io/docs/languages/go/quickstart/" drobecky: ["Docs", "Languages", "Go", "Quick start"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:49:23" znaku: 6452 slov: 725 kodovani: "utf-8" sha256: "184ee7cb4de30c72851b9270e7f3279d69633746a5fa26066b5177c9bf7985b3" --- # Quick start This guide gets you started with gRPC in Go with a simple working example. Contents # Quick start This guide gets you started with gRPC in Go with a simple working example. ### Prerequisites - **[Go](https://golang.org)**, any one of the **two latest major** [releases of Go](https://golang.org/doc/devel/release.html). For installation instructions, see Go’s [Getting Started](https://golang.org/doc/install) guide. - **[Protocol buffer](https://protobuf.dev) compiler**, `protoc`, [version 3](https://protobuf.dev/programming-guides/proto3). For installation instructions, see [Protocol Buffer Compiler Installation](/docs/protoc-installation/). - **Go plugins** for the protocol compiler: 1. Install the protocol compiler plugins for Go using the following commands: `go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest` 2. Update your `PATH` so that the `protoc` compiler can find the plugins: `export PATH="$PATH:$(go env GOPATH)/bin"` ### Get the example code The example code is part of the [grpc-go](https://github.com/grpc/grpc-go) repo. 1. [Download the repo as a zip file](https://github.com/grpc/grpc-go/archive/v1.83.2.zip) and unzip it, or clone the repo: `git clone -b v1.83.2 --depth 1 https://github.com/grpc/grpc-go` 2. Change to the quick start example directory: `cd grpc-go/examples/helloworld` ### Run the example From the `examples/helloworld` directory: 1. Compile and execute the server code: `go run greeter_server/main.go` 2. From a different terminal, compile and execute the client code to see the client output: `go run greeter_client/main.go Greeting: Hello world` Congratulations! You’ve just run a client-server application with gRPC. ### Update the gRPC service In this section you’ll update the application with an extra server method. The gRPC service is defined using [protocol buffers](https://protobuf.dev). To learn more about how to define a service in a `.proto` file see [Basics tutorial](../basics/). For now, all you need to know is that both the server and the client stub have a `SayHello()` RPC method that takes a `HelloRequest` parameter from the client and returns a `HelloReply` from the server, and that the method is defined like this: ``` // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` Open `helloworld/helloworld.proto` and add a new `SayHelloAgain()` method, with the same request and response types: ``` // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} // Sends another greeting rpc SayHelloAgain (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` Remember to save the file! ### Regenerate gRPC code Before you can use the new service method, you need to recompile the updated `.proto` file. While still in the `examples/helloworld` directory, run the following command: ``` protoc --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ helloworld/helloworld.proto ``` This will regenerate the `helloworld/helloworld.pb.go` and `helloworld/helloworld_grpc.pb.go` files, which contain: - Code for populating, serializing, and retrieving `HelloRequest` and `HelloReply` message types. - Generated client and server code. ### Update and run the application You have regenerated server and client code, but you still need to implement and call the new method in the human-written parts of the example application. #### Update the server Open `greeter_server/main.go` and add the following function to it: ``` func (s *server) SayHelloAgain(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { return &pb.HelloReply{Message: "Hello again " + in.GetName()}, nil } ``` #### Update the client Open `greeter_client/main.go` to add the following code to the end of the `main()` function body: ``` r, err = c.SayHelloAgain(ctx, &pb.HelloRequest{Name: *name}) if err != nil { log.Fatalf("could not greet: %v", err) } log.Printf("Greeting: %s", r.GetMessage()) ``` Remember to save your changes. #### Run! Run the client and server like you did before. Execute the following commands from the `examples/helloworld` directory: 1. Run the server: `go run greeter_server/main.go` 2. From another terminal, run the client. This time, add a name as a command-line argument: `go run greeter_client/main.go --name=Alice` You’ll see the following output: `Greeting: Hello Alice Greeting: Hello again Alice` ### What’s next - Learn how gRPC works in [Introduction to gRPC](/docs/what-is-grpc/introduction/) and [Core concepts](/docs/what-is-grpc/core-concepts/) . - Work through the [Basics tutorial](../basics/) . - Explore the [API reference](../api) . Last modified May 11, 2026: [Replace developers.google.com/protocol-buffers with protobuf.dev (#1502) (2e86d79)](https://github.com/grpc/grpc.io/commit/2e86d797df142cc555dced79016519515cc24f7a) [View page source](https://github.com/grpc/grpc.io/tree/main/content/en/docs/languages/go/quickstart.md) [Edit this page](https://github.com/grpc/grpc.io/edit/main/content/en/docs/languages/go/quickstart.md) [Create child page](https://github.com/grpc/grpc.io/new/main/content/en/docs/languages/go/quickstart.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A) [Create documentation issue](https://github.com/grpc/grpc.io/issues/new?title=Quick%20start) [Create project issue](https://github.com/grpc/grpc.io/issues/new)