You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.2 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # gRPC-Go
  2. [![Build Status](https://travis-ci.org/grpc/grpc-go.svg)](https://travis-ci.org/grpc/grpc-go)
  3. [![GoDoc](https://godoc.org/google.golang.org/grpc?status.svg)](https://godoc.org/google.golang.org/grpc)
  4. [![GoReportCard](https://goreportcard.com/badge/grpc/grpc-go)](https://goreportcard.com/report/github.com/grpc/grpc-go)
  5. The Go implementation of [gRPC](https://grpc.io/): A high performance, open
  6. source, general RPC framework that puts mobile and HTTP/2 first. For more
  7. information see the [gRPC Quick Start:
  8. Go](https://grpc.io/docs/quickstart/go.html) guide.
  9. Installation
  10. ------------
  11. To install this package, you need to install Go and setup your Go workspace on
  12. your computer. The simplest way to install the library is to run:
  13. ```
  14. $ go get -u google.golang.org/grpc
  15. ```
  16. With Go module support (Go 1.11+), simply `import "google.golang.org/grpc"` in
  17. your source code and `go [build|run|test]` will automatically download the
  18. necessary dependencies ([Go modules
  19. ref](https://github.com/golang/go/wiki/Modules)).
  20. If you are trying to access grpc-go from within China, please see the
  21. [FAQ](#FAQ) below.
  22. Prerequisites
  23. -------------
  24. gRPC-Go requires Go 1.9 or later.
  25. Documentation
  26. -------------
  27. - See [godoc](https://godoc.org/google.golang.org/grpc) for package and API
  28. descriptions.
  29. - Documentation on specific topics can be found in the [Documentation
  30. directory](Documentation/).
  31. - Examples can be found in the [examples directory](examples/).
  32. Performance
  33. -----------
  34. Performance benchmark data for grpc-go and other languages is maintained in
  35. [this
  36. dashboard](https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5652536396611584&widget=490377658&container=1286539696).
  37. Status
  38. ------
  39. General Availability [Google Cloud Platform Launch
  40. Stages](https://cloud.google.com/terms/launch-stages).
  41. FAQ
  42. ---
  43. #### I/O Timeout Errors
  44. The `golang.org` domain may be blocked from some countries. `go get` usually
  45. produces an error like the following when this happens:
  46. ```
  47. $ go get -u google.golang.org/grpc
  48. package google.golang.org/grpc: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
  49. ```
  50. To build Go code, there are several options:
  51. - Set up a VPN and access google.golang.org through that.
  52. - Without Go module support: `git clone` the repo manually:
  53. ```
  54. git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
  55. ```
  56. You will need to do the same for all of grpc's dependencies in `golang.org`,
  57. e.g. `golang.org/x/net`.
  58. - With Go module support: it is possible to use the `replace` feature of `go
  59. mod` to create aliases for golang.org packages. In your project's directory:
  60. ```
  61. go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest
  62. go mod tidy
  63. go mod vendor
  64. go build -mod=vendor
  65. ```
  66. Again, this will need to be done for all transitive dependencies hosted on
  67. golang.org as well. Please refer to [this
  68. issue](https://github.com/golang/go/issues/28652) in the golang repo regarding
  69. this concern.
  70. #### Compiling error, undefined: grpc.SupportPackageIsVersion
  71. Please update proto package, gRPC package and rebuild the proto files:
  72. - `go get -u github.com/golang/protobuf/{proto,protoc-gen-go}`
  73. - `go get -u google.golang.org/grpc`
  74. - `protoc --go_out=plugins=grpc:. *.proto`
  75. #### How to turn on logging
  76. The default logger is controlled by the environment variables. Turn everything
  77. on by setting:
  78. ```
  79. GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info
  80. ```
  81. #### The RPC failed with error `"code = Unavailable desc = transport is closing"`
  82. This error means the connection the RPC is using was closed, and there are many
  83. possible reasons, including:
  84. 1. mis-configured transport credentials, connection failed on handshaking
  85. 1. bytes disrupted, possibly by a proxy in between
  86. 1. server shutdown
  87. It can be tricky to debug this because the error happens on the client side but
  88. the root cause of the connection being closed is on the server side. Turn on
  89. logging on __both client and server__, and see if there are any transport
  90. errors.