go: Fix things staticcheck complains about
Client: go
Staticcheck is the recommended replacement of the frozen and deprecated
official golint linter [1].
Fix the things it complained about (or add lint:ignore directive) in:
- lib/go/thrift
- lib/go/test/tests
- tutorial/go/src
- test/go/src
- compiler generated code
The majority of the fixes are in the following categories:
- Use of deprecated function (mainly the TConfiguration related ones)
- Redundant break in switch cases
- Unused and unexported variables/fields/functions
Also in the same spirit as fb539ae, remove the error return from
NewTSSLSocket as it can never be non-nil.
This change will be cherry-picked into 0.15.0 branch after merged.
[1]: https://groups.google.com/g/golang-nuts/c/rCP70Aq_tBc
diff --git a/tutorial/go/src/handler.go b/tutorial/go/src/handler.go
index 7645fc2..a9edd26 100644
--- a/tutorial/go/src/handler.go
+++ b/tutorial/go/src/handler.go
@@ -51,13 +51,10 @@
switch w.Op {
case tutorial.Operation_ADD:
val = w.Num1 + w.Num2
- break
case tutorial.Operation_SUBTRACT:
val = w.Num1 - w.Num2
- break
case tutorial.Operation_MULTIPLY:
val = w.Num1 * w.Num2
- break
case tutorial.Operation_DIVIDE:
if w.Num2 == 0 {
ouch := tutorial.NewInvalidOperation()
@@ -67,7 +64,6 @@
return
}
val = w.Num1 / w.Num2
- break
default:
ouch := tutorial.NewInvalidOperation()
ouch.WhatOp = int32(w.Op)
@@ -93,7 +89,7 @@
func (p *CalculatorHandler) GetStruct(ctx context.Context, key int32) (*shared.SharedStruct, error) {
fmt.Print("getStruct(", key, ")\n")
- v, _ := p.log[int(key)]
+ v := p.log[int(key)]
return v, nil
}