@@ -6,18 +6,22 @@ description: This guide gets you started with gRPC in Go with a simple working e
6
6
protoc-version : 3.11.4
7
7
---
8
8
9
+ <style type =" text/css " >
10
+ ol ol { list-style-type : lower-alpha !important ; }
11
+ </style >
12
+
9
13
### Prerequisites
10
14
11
- - ** Go ** version 1.12+. For installation instructions, see Go's [ Getting
12
- Started] ( https://golang.org/doc/install ) guide.
15
+ - ** [ Go ] [ ] ** , any one of the ** three latest major ** [ releases of Go ] [ ] . For
16
+ installation instructions, see Go's [ Getting Started] [ ] guide.
13
17
14
18
#### gRPC
15
19
16
20
Use the following command to install gRPC as a [ module] [ ] :
17
21
18
22
``` sh
19
23
$ export GO111MODULE=on # Enable module-aware mode
20
- $ go get -u google.golang.org/grpc@{{< param grpc_release_tag > }}
24
+ $ go get google.golang.org/grpc@{{< param grpc_release_tag > }}
21
25
```
22
26
23
27
#### Protocol Buffers
@@ -28,43 +32,37 @@ for service definitions and data serialization, and the example code uses
28
32
29
33
1 . Install the ` protoc ` compiler:
30
34
31
- - macOS:
32
-
33
- ``` sh
34
- $ brew install protobuf
35
- ```
36
-
37
- - Any OS:
35
+ 1 . Download a zip file of the latest version of pre-compiled binaries for
36
+ your operating system from [ github.com/google/protobuf/releases] [ ]
37
+ (` protoc-<version>-<os><arch>.zip ` ). For example:
38
38
39
- 1. Download a zip file of the latest version of pre-compiled binaries for
40
- your operating system from [github.com/google/protobuf/releases][]
41
- (` protoc-< version> -< os><arch> .zip` ). For example:
39
+ ``` sh
40
+ $ PB_REL=" https://github.com/protocolbuffers/protobuf/releases"
41
+ $ curl -LO $PB_REL /download/v{{< param protoc-version > }}/protoc-{{< param protoc-version > }}-linux-x86_64.zip
42
+ ```
42
43
43
- ` ` ` sh
44
- $ PB_REL=" https://github.com/protocolbuffers/protobuf/releases"
45
- $ curl -LO $PB_REL /download/v{{< param protoc-version > }}/protoc-{{< param protoc-version > }}-linux-x86_64.zip
46
- ` ` `
44
+ 2. Unzip the file under ` $HOME /.local` or a directory of your choice. For
45
+ example:
47
46
48
- 2. Unzip the file under ` $HOME /local` or a directory of your choice. For
49
- example:
47
+ ` ` ` sh
48
+ $ unzip protoc-{{< param protoc-version > }}-linux-x86_64.zip -d $HOME /.local
49
+ ` ` `
50
50
51
- ` ` ` sh
52
- $ unzip protoc-{{< param protoc-version > }}-linux-x86_64.zip -d $HOME /local
53
- ` ` `
51
+ 3. Update your environment' s path variable to include the path to the
52
+ `protoc` executable. For example:
54
53
55
- 3. Update your environment' s path variable to include the path to the
56
- `protoc` executable. For example:
54
+ ```sh
55
+ $ export PATH="$PATH:$HOME/.local/bin"
56
+ ```
57
57
58
- ```sh
59
- $ export PATH="$PATH:$HOME/local/bin"
60
- ```
58
+ > **MacOS note**: Using [Homebrew][]? Simply run: `brew install protobuf`.
61
59
62
60
2. The `protoc` plugin for Go (`protoc-gen-go`) was installed as a dependency
63
61
of the `grpc` module. You can confirm this, or install the plugin, using the
64
62
following command:
65
63
66
64
```sh
67
- $ go get -u github.com/golang/protobuf/protoc-gen-go
65
+ $ go get github.com/golang/protobuf/protoc-gen-go
68
66
```
69
67
70
68
3. Update your `PATH` so that the `protoc` compiler can find the plugin:
@@ -272,6 +270,10 @@ from the `examples/helloworld` directory:
272
270
documentation](https://godoc.org/google.golang.org/grpc).
273
271
274
272
[github.com/google/protobuf/releases]: https://github.com/google/protobuf/releases
273
+ [Getting Started]: https://golang.org/doc/install
274
+ [Go]: https://golang.org
275
+ [Homebrew]: https://brew.sh
275
276
[module]: https://github.com/golang/go/wiki/Modules
276
277
[pb]: https://developers.google.com/protocol-buffers
277
278
[proto3]: https://developers.google.com/protocol-buffers/docs/proto3
279
+ [releases of Go]: https://golang.org/doc/devel/release.html
0 commit comments