Читать книгу Practical Go - Amit Saha - Страница 15
Windows
ОглавлениеNOTE You will need to open a Windows PowerShell window as an administrator to run the steps.
To install the protocol buffers compiler, run the following steps:
1 Download the latest release (3.16.0 at the time of this book's writing) file from https://github.com/protocolbuffers/protobuf/releases, corresponding to your architecture. Look for a file named protoc-3.16.0-win64.zip in the Assets section.
2 Then create a directory where you will store the compiler. For example, in C:\Program Files as follows: PS C:\> mkdir 'C:\Program Files\protoc-3.16.0' .
3 Next, extract the downloaded .zip file inside that directory. Run the following command while you are inside the directory where you downloaded the .zip file: PS C:\> Expand-Archive.\protoc-3.16.0-win64\ -DestinationPath 'C:\Program Files\protoc-3.16.0 ’.
4 Finally, update the Path environment variable to add the above path: PS C:\> [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\protoc-3.16.0\bin", "Machine").
Open a new PowerShell window, and run the command protoc --version
:
$ protoc --version libprotoc 3.16.0
If you see an output like the one above, you are ready to move on to the next step.
To install the protobuf compiler for Go, protoc-gen-go tool
(release v1.26), run the following command from a terminal window:
C:\> go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
To install the gRPC plug-in for Go, protoc-gen-go-grpc
(release v1.1) tool, run the following command:
C:\> go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
Open a new Windows PowerShell Window, and run the following commands:
$ protoc-gen-go --version protoc-gen-go v1.26.0 $ protoc-gen-go-grpc --version protoc-gen-go-grpc 1.1.0
If you see an output like the one above, the tools have been installed successfully.