Skip to content

Commit 0eb17c3

Browse files
Add correct comment, remove redundant vars and error, use short form (#3206)
1 parent 965603a commit 0eb17c3

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

runtime/mux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func WithForwardResponseOption(forwardResponseOption func(context.Context, http.
8080
}
8181
}
8282

83-
// WithEscapingType sets the escaping type. See the definitions of UnescapingMode
83+
// WithUnescapingMode sets the escaping type. See the definitions of UnescapingMode
8484
// for more information.
8585
func WithUnescapingMode(mode UnescapingMode) ServeMuxOption {
8686
return func(serveMux *ServeMux) {
@@ -231,7 +231,6 @@ func WithHealthEndpointAt(healthCheckClient grpc_health_v1.HealthClient, endpoin
231231
w.Header().Set("Content-Type", "application/json")
232232

233233
if resp.GetStatus() != grpc_health_v1.HealthCheckResponse_SERVING {
234-
var err error
235234
switch resp.GetStatus() {
236235
case grpc_health_v1.HealthCheckResponse_NOT_SERVING, grpc_health_v1.HealthCheckResponse_UNKNOWN:
237236
err = status.Error(codes.Unavailable, resp.String())

runtime/pattern.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ var (
1515
ErrNotMatch = errors.New("not match to the path pattern")
1616
// ErrInvalidPattern indicates that the given definition of Pattern is not valid.
1717
ErrInvalidPattern = errors.New("invalid pattern")
18-
// ErrMalformedSequence indicates that an escape sequence was malformed.
19-
ErrMalformedSequence = errors.New("malformed escape sequence")
2018
)
2119

2220
type MalformedSequenceError string

runtime/query.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ type DefaultQueryParser struct{}
4747
// A value is ignored if its key starts with one of the elements in "filter".
4848
func (*DefaultQueryParser) Parse(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error {
4949
for key, values := range values {
50-
match := valuesKeyRegexp.FindStringSubmatch(key)
51-
if len(match) == 3 {
50+
if match := valuesKeyRegexp.FindStringSubmatch(key); len(match) == 3 {
5251
key = match[1]
5352
values = append([]string{match[2]}, values...)
5453
}
@@ -321,15 +320,13 @@ func parseMessage(msgDescriptor protoreflect.MessageDescriptor, value string) (p
321320
msg = fm
322321
case "google.protobuf.Value":
323322
var v structpb.Value
324-
err := protojson.Unmarshal([]byte(value), &v)
325-
if err != nil {
323+
if err := protojson.Unmarshal([]byte(value), &v); err != nil {
326324
return protoreflect.Value{}, err
327325
}
328326
msg = &v
329327
case "google.protobuf.Struct":
330328
var v structpb.Struct
331-
err := protojson.Unmarshal([]byte(value), &v)
332-
if err != nil {
329+
if err := protojson.Unmarshal([]byte(value), &v); err != nil {
333330
return protoreflect.Value{}, err
334331
}
335332
msg = &v

0 commit comments

Comments
 (0)