mirror of https://github.com/grpc/grpc-go.git
Various simplifications (gosimple)
This fixes: clientconn.go:948:3: should write m = cc.sc.Methods[method[:i+1]] instead of m, _ = cc.sc.Methods[method[:i+1]] (S1005) encoding/proto/proto_test.go:43:5: should use !bytes.Equal(p.GetBody(), expectedBody) instead (S1004) resolver/dns/dns_resolver.go:260:2: should merge variable declaration with assignment on next line (S1021) resolver/dns/dns_resolver.go:344:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008)
This commit is contained in:
parent
4d9544a0fd
commit
35a2846daa
|
@ -945,7 +945,7 @@ func (cc *ClientConn) GetMethodConfig(method string) MethodConfig {
|
|||
m, ok := cc.sc.Methods[method]
|
||||
if !ok {
|
||||
i := strings.LastIndex(method, "/")
|
||||
m, _ = cc.sc.Methods[method[:i+1]]
|
||||
m = cc.sc.Methods[method[:i+1]]
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func marshalAndUnmarshal(t *testing.T, codec encoding.Codec, expectedBody []byte
|
|||
t.Errorf("codec.Unmarshal(_) returned an error")
|
||||
}
|
||||
|
||||
if bytes.Compare(p.GetBody(), expectedBody) != 0 {
|
||||
if !bytes.Equal(p.GetBody(), expectedBody) {
|
||||
t.Errorf("Unexpected body; got %v; want %v", p.GetBody(), expectedBody)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,8 +257,7 @@ func (d *dnsResolver) lookupHost() []resolver.Address {
|
|||
}
|
||||
|
||||
func (d *dnsResolver) lookup() ([]resolver.Address, string) {
|
||||
var newAddrs []resolver.Address
|
||||
newAddrs = d.lookupSRV()
|
||||
newAddrs := d.lookupSRV()
|
||||
// Support fallback to non-balancer address.
|
||||
newAddrs = append(newAddrs, d.lookupHost()...)
|
||||
sc := d.lookupTXT()
|
||||
|
@ -341,10 +340,7 @@ func chosenByPercentage(a *int) bool {
|
|||
}
|
||||
s := rand.NewSource(time.Now().UnixNano())
|
||||
r := rand.New(s)
|
||||
if r.Intn(100)+1 > *a {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return r.Intn(100)+1 <= *a
|
||||
}
|
||||
|
||||
func canaryingSC(js string) string {
|
||||
|
|
Loading…
Reference in New Issue