Skip to content

Commit b6fde8c

Browse files
authored
vet: add check for trailing spaces (#7576)
* vet: trailing spaces check
1 parent 7fb7ac7 commit b6fde8c

File tree

29 files changed

+145
-141
lines changed

29 files changed

+145
-141
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ How to get your contributions merged smoothly and quickly.
2525
is a great place to start. These issues are well-documented and usually can be
2626
resolved with a single pull request.
2727

28-
- If you are adding a new file, make sure it has the copyright message template
29-
at the top as a comment. You can copy over the message from an existing file
28+
- If you are adding a new file, make sure it has the copyright message template
29+
at the top as a comment. You can copy over the message from an existing file
3030
and update the year.
3131

3232
- The grpc package should only depend on standard Go packages and a small number
@@ -41,10 +41,10 @@ How to get your contributions merged smoothly and quickly.
4141
- Provide a good **PR description** as a record of **what** change is being made
4242
and **why** it was made. Link to a github issue if it exists.
4343

44-
- If you want to fix formatting or style, consider whether your changes are an
45-
obvious improvement or might be considered a personal preference. If a style
46-
change is based on preference, it likely will not be accepted. If it corrects
47-
widely agreed-upon anti-patterns, then please do create a PR and explain the
44+
- If you want to fix formatting or style, consider whether your changes are an
45+
obvious improvement or might be considered a personal preference. If a style
46+
change is based on preference, it likely will not be accepted. If it corrects
47+
widely agreed-upon anti-patterns, then please do create a PR and explain the
4848
benefits of the change.
4949

5050
- Unless your PR is trivial, you should expect there will be reviewer comments

Documentation/server-reflection-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The `list` command lists services exposed at a given port:
103103
- Describe all services
104104

105105
The `describe` command inspects a service given its full name (in the format
106-
of \<package\>.\<service\>).
106+
of \<package\>.\<service\>).
107107

108108
```sh
109109
$ grpcurl -plaintext localhost:50051 describe helloworld.Greeter

authz/grpc_authz_end2end_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var authzTests = map[string]struct {
7878
"DeniesRPCMatchInDenyNoMatchInAllow": {
7979
authzPolicy: `{
8080
"name": "authz",
81-
"allow_rules":
81+
"allow_rules":
8282
[
8383
{
8484
"name": "allow_StreamingOutputCall",
@@ -166,11 +166,11 @@ var authzTests = map[string]struct {
166166
"/grpc.testing.TestService/UnaryCall",
167167
"/grpc.testing.TestService/StreamingInputCall"
168168
],
169-
"headers":
169+
"headers":
170170
[
171171
{
172172
"key": "key-abc",
173-
"values":
173+
"values":
174174
[
175175
"val-abc",
176176
"val-def"
@@ -250,7 +250,7 @@ var authzTests = map[string]struct {
250250
[
251251
{
252252
"name": "allow_StreamingOutputCall",
253-
"request":
253+
"request":
254254
{
255255
"paths":
256256
[

authz/grpc_authz_server_interceptors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func (s) TestNewStatic(t *testing.T) {
5757
wantErr: fmt.Errorf(`"name" is not present`),
5858
},
5959
"ValidPolicyCreatesInterceptor": {
60-
authzPolicy: `{
60+
authzPolicy: `{
6161
"name": "authz",
62-
"allow_rules":
62+
"allow_rules":
6363
[
6464
{
6565
"name": "allow_all"

cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616

1717
# Uncomment to enable debugging.
18-
# set -x
18+
# set -x
1919

2020
WORKDIR="$(dirname $0)"
2121
TEMPDIR=$(mktemp -d)
@@ -24,7 +24,7 @@ trap "rm -rf ${TEMPDIR}" EXIT
2424

2525
# Build protoc-gen-go-grpc binary and add to $PATH.
2626
pushd "${WORKDIR}"
27-
go build -o "${TEMPDIR}" .
27+
go build -o "${TEMPDIR}" .
2828
PATH="${TEMPDIR}:${PATH}"
2929
popd
3030

@@ -38,7 +38,7 @@ GENFILE="${TEMPDIR}/examples/route_guide/routeguide/route_guide_grpc.pb.go"
3838

3939
# diff is piped to [[ $? == 1 ]] to avoid exiting on diff but exit on error
4040
# (like if the file was not found). See man diff for more info.
41-
DIFF=$(diff "${GOLDENFILE}" "${GENFILE}" || [[ $? == 1 ]])
41+
DIFF=$(diff "${GOLDENFILE}" "${GENFILE}" || [[ $? == 1 ]])
4242
if [[ -n "${DIFF}" ]]; then
4343
echo -e "ERROR: Generated file differs from golden file:\n${DIFF}"
4444
echo -e "If you have made recent changes to protoc-gen-go-grpc," \

examples/features/advancedtls/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The clients are designed to call these servers with varying configurations of cr
1616
```
1717
# Run the server
1818
$ go run server/main.go -credentials_directory $(pwd)/creds
19-
# Run the clients from the `grpc-go/examples/features/advancedtls` directory
19+
# Run the clients from the `grpc-go/examples/features/advancedtls` directory
2020
$ go run client/main.go -credentials_directory $(pwd)/creds
2121
```
2222

examples/features/advancedtls/creds/client_cert.pem

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ Certificate:
4949
6e:bb:bb
5050
Exponent: 65537 (0x10001)
5151
X509v3 extensions:
52-
X509v3 Subject Key Identifier:
52+
X509v3 Subject Key Identifier:
5353
DE:03:BD:A3:0E:63:F4:97:C2:52:70:63:E8:BE:A9:DF:F1:9A:7B:56
54-
X509v3 Authority Key Identifier:
54+
X509v3 Authority Key Identifier:
5555
50:76:C3:5C:6B:12:E1:92:0F:28:F8:F2:43:A6:80:C2:9C:E8:56:D6
56-
X509v3 Basic Constraints:
56+
X509v3 Basic Constraints:
5757
CA:FALSE
58-
X509v3 Key Usage:
58+
X509v3 Key Usage:
5959
Digital Signature, Key Encipherment
60-
X509v3 Subject Alternative Name:
60+
X509v3 Subject Alternative Name:
6161
DNS:localhost, IP Address:0.0.0.0
6262
Signature Algorithm: sha256WithRSAEncryption
6363
Signature Value:

examples/features/advancedtls/creds/client_cert_revoked.pem

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ Certificate:
4949
6e:bb:bb
5050
Exponent: 65537 (0x10001)
5151
X509v3 extensions:
52-
X509v3 Subject Key Identifier:
52+
X509v3 Subject Key Identifier:
5353
DE:03:BD:A3:0E:63:F4:97:C2:52:70:63:E8:BE:A9:DF:F1:9A:7B:56
54-
X509v3 Authority Key Identifier:
54+
X509v3 Authority Key Identifier:
5555
50:76:C3:5C:6B:12:E1:92:0F:28:F8:F2:43:A6:80:C2:9C:E8:56:D6
56-
X509v3 Basic Constraints:
56+
X509v3 Basic Constraints:
5757
CA:FALSE
58-
X509v3 Key Usage:
58+
X509v3 Key Usage:
5959
Digital Signature, Key Encipherment
60-
X509v3 Subject Alternative Name:
60+
X509v3 Subject Alternative Name:
6161
DNS:localhost, IP Address:0.0.0.0
6262
Signature Algorithm: sha256WithRSAEncryption
6363
Signature Value:

examples/features/advancedtls/creds/server_cert.pem

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ Certificate:
4949
03:71:c1
5050
Exponent: 65537 (0x10001)
5151
X509v3 extensions:
52-
X509v3 Subject Key Identifier:
52+
X509v3 Subject Key Identifier:
5353
4C:57:E2:72:97:CF:DC:C4:B8:4E:DB:D4:C1:C6:3D:AE:EF:D7:0A:19
54-
X509v3 Authority Key Identifier:
54+
X509v3 Authority Key Identifier:
5555
50:76:C3:5C:6B:12:E1:92:0F:28:F8:F2:43:A6:80:C2:9C:E8:56:D6
56-
X509v3 Basic Constraints:
56+
X509v3 Basic Constraints:
5757
CA:FALSE
58-
X509v3 Key Usage:
58+
X509v3 Key Usage:
5959
Digital Signature, Key Encipherment
60-
X509v3 Subject Alternative Name:
60+
X509v3 Subject Alternative Name:
6161
DNS:localhost, IP Address:0.0.0.0
6262
Signature Algorithm: sha256WithRSAEncryption
6363
Signature Value:

examples/features/advancedtls/creds/server_cert_revoked.pem

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ Certificate:
4949
03:71:c1
5050
Exponent: 65537 (0x10001)
5151
X509v3 extensions:
52-
X509v3 Subject Key Identifier:
52+
X509v3 Subject Key Identifier:
5353
4C:57:E2:72:97:CF:DC:C4:B8:4E:DB:D4:C1:C6:3D:AE:EF:D7:0A:19
54-
X509v3 Authority Key Identifier:
54+
X509v3 Authority Key Identifier:
5555
50:76:C3:5C:6B:12:E1:92:0F:28:F8:F2:43:A6:80:C2:9C:E8:56:D6
56-
X509v3 Basic Constraints:
56+
X509v3 Basic Constraints:
5757
CA:FALSE
58-
X509v3 Key Usage:
58+
X509v3 Key Usage:
5959
Digital Signature, Key Encipherment
60-
X509v3 Subject Alternative Name:
60+
X509v3 Subject Alternative Name:
6161
DNS:localhost, IP Address:0.0.0.0
6262
Signature Algorithm: sha256WithRSAEncryption
6363
Signature Value:

examples/features/debugging/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Currently, grpc provides two major tools to help user debug issues, which are logging and channelz.
44

55
## Logs
6-
gRPC has put substantial logging instruments on critical paths of gRPC to help users debug issues.
6+
gRPC has put substantial logging instruments on critical paths of gRPC to help users debug issues.
77
The [Log Levels](https://github.com/grpc/grpc-go/blob/master/Documentation/log_levels.md) doc describes
88
what each log level means in the gRPC context.
99

10-
To turn on the logs for debugging, run the code with the following environment variable:
11-
`GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info`.
10+
To turn on the logs for debugging, run the code with the following environment variable:
11+
`GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info`.
1212

1313
## Channelz
1414
We also provide a runtime debugging tool, Channelz, to help users with live debugging.
@@ -17,7 +17,7 @@ See the channelz blog post here ([link](https://grpc.io/blog/a-short-introductio
1717
details about how to use channelz service to debug live program.
1818

1919
## Try it
20-
The example is able to showcase how logging and channelz can help with debugging. See the channelz
20+
The example is able to showcase how logging and channelz can help with debugging. See the channelz
2121
blog post linked above for full explanation.
2222

2323
```

examples/features/encryption/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ create grpc
2929
base on TLS. Refer to the
3030
[godoc](https://godoc.org/google.golang.org/grpc/credentials) for details.
3131

32-
In our example, we use the public/private keys created ahead:
33-
* "server_cert.pem" contains the server certificate (public key).
34-
* "server_key.pem" contains the server private key.
32+
In our example, we use the public/private keys created ahead:
33+
* "server_cert.pem" contains the server certificate (public key).
34+
* "server_key.pem" contains the server private key.
3535
* "ca_cert.pem" contains the certificate (certificate authority)
3636
that can verify the server's certificate.
3737

@@ -56,7 +56,7 @@ And finally we make an RPC call over the created `grpc.ClientConn` to test the s
5656
connection based upon TLS is successfully up.
5757

5858
### ALTS
59-
NOTE: ALTS currently needs special early access permission on GCP. You can ask
59+
NOTE: ALTS currently needs special early access permission on GCP. You can ask
6060
about the detailed process in https://groups.google.com/forum/#!forum/grpc-io.
6161

6262
ALTS is the Google's Application Layer Transport Security, which supports mutual
@@ -93,12 +93,12 @@ allows users to configure mutual TLS at the connection level.
9393

9494
In this example, we use the following public/private keys created ahead of time:
9595

96-
* "server_cert.pem" contains the server's certificate (public key).
97-
* "server_key.pem" contains the server's private key.
96+
* "server_cert.pem" contains the server's certificate (public key).
97+
* "server_key.pem" contains the server's private key.
9898
* "ca_cert.pem" contains the certificate of the certificate authority that can
9999
verify the server's certificate.
100-
* "client_cert.pem" contains the client's certificate (public key).
101-
* "client_key.pem" contains the client's private key.
100+
* "client_cert.pem" contains the client's certificate (public key).
101+
* "client_key.pem" contains the client's private key.
102102
* "client_ca_cert.pem" contains the certificate of the certificate authority
103103
that can verify the client's certificate.
104104

examples/features/health/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
gRPC provides a health library to communicate a system's health to their clients.
44
It works by providing a service definition via the [health/v1](https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto) api.
55

6-
By using the health library, clients can gracefully avoid using servers as they encounter issues.
6+
By using the health library, clients can gracefully avoid using servers as they encounter issues.
77
Most languages provide an implementation out of box, making it interoperable between systems.
88

99
## Try it
@@ -30,7 +30,7 @@ This configuration indicates which backend `serviceName` should be inspected whe
3030
An empty string (`""`) typically indicates the overall health of a server should be reported.
3131

3232
```go
33-
// import grpc/health to enable transparent client side checking
33+
// import grpc/health to enable transparent client side checking
3434
import _ "google.golang.org/grpc/health"
3535

3636
// set up appropriate service config
@@ -59,6 +59,6 @@ This state is often seen at the start up of a server instance.
5959
Conversely, `NOT_SERVING` indicates the system is unable to service requests at the time.
6060

6161
`SERVICE_UNKNOWN` communicates the `serviceName` requested by the client is not known by the server.
62-
This status is only reported by the `Watch()` call.
62+
This status is only reported by the `Watch()` call.
6363

6464
A server may toggle its health using `healthServer.SetServingStatus("serviceName", servingStatus)`.

examples/features/metadata_interceptor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (s *wrappedStream) Context() context.Context {
5757
}
5858

5959
func SomeStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
60-
// Get the incoming metadata from the RPC context, and add a new
60+
// Get the incoming metadata from the RPC context, and add a new
6161
// key-value pair to it.
6262
md, ok := metadata.FromIncomingContext(ctx)
6363
md.Append("key1", "value1")
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Stats Monitoring Handler
22

3-
This example demonstrates the use of the [`stats`](https://pkg.go.dev/google.golang.org/grpc/stats) package for reporting various
4-
network and RPC stats.
5-
_Note that all fields are READ-ONLY and the APIs of the `stats` package are
3+
This example demonstrates the use of the [`stats`](https://pkg.go.dev/google.golang.org/grpc/stats) package for reporting various
4+
network and RPC stats.
5+
_Note that all fields are READ-ONLY and the APIs of the `stats` package are
66
experimental_.
77

88
## Try it
@@ -17,42 +17,42 @@ go run client/main.go
1717

1818
## Explanation
1919

20-
gRPC provides a mechanism to hook on to various events (phases) of the
21-
request-response network cycle through the [`stats.Handler`](https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface. To access
22-
these events, a concrete type that implements `stats.Handler` should be passed to
23-
`grpc.WithStatsHandler()` on the client side and `grpc.StatsHandler()` on the
20+
gRPC provides a mechanism to hook on to various events (phases) of the
21+
request-response network cycle through the [`stats.Handler`](https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface. To access
22+
these events, a concrete type that implements `stats.Handler` should be passed to
23+
`grpc.WithStatsHandler()` on the client side and `grpc.StatsHandler()` on the
2424
server side.
2525

26-
The `HandleRPC(context.Context, RPCStats)` method on `stats.Handler` is called
27-
multiple times during a request-response cycle, and various event stats are
28-
passed to its `RPCStats` parameter (an interface). The concrete types that
29-
implement this interface are: `*stats.Begin`, `*stats.InHeader`, `*stats.InPayload`,
30-
`*stats.InTrailer`, `*stats.OutHeader`, `*stats.OutPayload`, `*stats.OutTrailer`, and
26+
The `HandleRPC(context.Context, RPCStats)` method on `stats.Handler` is called
27+
multiple times during a request-response cycle, and various event stats are
28+
passed to its `RPCStats` parameter (an interface). The concrete types that
29+
implement this interface are: `*stats.Begin`, `*stats.InHeader`, `*stats.InPayload`,
30+
`*stats.InTrailer`, `*stats.OutHeader`, `*stats.OutPayload`, `*stats.OutTrailer`, and
3131
`*stats.End`. The order of these events differs on client and server.
3232

33-
Similarly, the `HandleConn(context.Context, ConnStats)` method on `stats.Handler`
34-
is called twice, once at the beginning of the connection with `*stats.ConnBegin`
33+
Similarly, the `HandleConn(context.Context, ConnStats)` method on `stats.Handler`
34+
is called twice, once at the beginning of the connection with `*stats.ConnBegin`
3535
and once at the end with `*stats.ConnEnd`.
3636

37-
The [`stats.Handler`](https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface also provides
38-
`TagRPC(context.Context, *RPCTagInfo) context.Context` and
39-
`TagConn(context.Context, *ConnTagInfo) context.Context` methods. These methods
37+
The [`stats.Handler`](https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface also provides
38+
`TagRPC(context.Context, *RPCTagInfo) context.Context` and
39+
`TagConn(context.Context, *ConnTagInfo) context.Context` methods. These methods
4040
are mainly used to attach network related information to the given context.
4141

42-
The `TagRPC(context.Context, *RPCTagInfo) context.Context` method returns a
43-
context from which the context used for the rest lifetime of the RPC will be
42+
The `TagRPC(context.Context, *RPCTagInfo) context.Context` method returns a
43+
context from which the context used for the rest lifetime of the RPC will be
4444
derived. This behavior is consistent between the gRPC client and server.
4545

46-
The context returned from
46+
The context returned from
4747
`TagConn(context.Context, *ConnTagInfo) context.Context` has varied lifespan:
4848

49-
- In the gRPC client:
50-
The context used for the rest lifetime of the RPC will NOT be derived from
51-
this context. Hence the information attached to this context can only be
49+
- In the gRPC client:
50+
The context used for the rest lifetime of the RPC will NOT be derived from
51+
this context. Hence the information attached to this context can only be
5252
consumed by `HandleConn(context.Context, ConnStats)` method.
53-
- In the gRPC server:
54-
The context used for the rest lifetime of the RPC will be derived from
53+
- In the gRPC server:
54+
The context used for the rest lifetime of the RPC will be derived from
5555
this context.
5656

57-
NOTE: The [stats](https://pkg.go.dev/google.golang.org/grpc/stats) package should only be used for network monitoring purposes,
57+
NOTE: The [stats](https://pkg.go.dev/google.golang.org/grpc/stats) package should only be used for network monitoring purposes,
5858
and not as an alternative to [interceptors](https://github.com/grpc/grpc-go/blob/master/examples/features/interceptor).

scripts/vet.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ not git grep "\"github.com/golang/protobuf/*" -- "*.go" ':(exclude)reflection/te
6767
# - Ensure all usages of grpc_testing package are renamed when importing.
6868
not git grep "\(import \|^\s*\)\"google.golang.org/grpc/interop/grpc_testing" -- "*.go"
6969

70+
# - Ensure that no trailing spaces are found.
71+
not git grep '[[:blank:]]$'
72+
7073
# - Ensure all xds proto imports are renamed to *pb or *grpc.
7174
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.pb.go' | not grep -v 'pb "\|grpc "'
7275

0 commit comments

Comments
 (0)