Skip to content

Commit

Permalink
chore(lint): fix issues found in new golangci-lint
Browse files Browse the repository at this point in the history
It looks like the GitHub Action doesn't have a pinned golangci-lint
version, so it's pulled in the latest (golangci-lint v1.54.0) which now
flags a few additional issues that it didn't previously.

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
  • Loading branch information
dnwe committed Aug 10, 2023
1 parent a997427 commit 362ac86
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ linters:
- lll
- misspell
- nakedret
- structcheck
- unparam
- varcheck
- unused

linters-settings:
dupl:
Expand Down
5 changes: 2 additions & 3 deletions idgenerator/idgenerator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ func TestRandomTimeStamped(t *testing.T) {

var latestTS uint64
for idx, traceID := range ids {
if new, old := traceID.High>>32, latestTS; new < old {
t.Errorf("[%d] expected a higher timestamp part in traceid but got: old: %d new: %d", idx, old, new)
if newVal, oldVal := traceID.High>>32, latestTS; newVal < oldVal {
t.Errorf("[%d] expected a higher timestamp part in traceid but got: old: %d new: %d", idx, oldVal, newVal)
}
latestTS = traceID.High >> 32
}

}
6 changes: 3 additions & 3 deletions middleware/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func NewClient(tracer *zipkin.Tracer, options ...ClientOption) (*Client, error)
}

// DoWithAppSpan wraps http.Client's Do with tracing using an application span.
func (c *Client) DoWithAppSpan(req *http.Request, name string) (res *http.Response, err error) {
func (c *Client) DoWithAppSpan(req *http.Request, name string) (*http.Response, error) {
var parentContext model.SpanContext

if span := zipkin.SpanFromContext(req.Context()); span != nil {
Expand All @@ -120,13 +120,13 @@ func (c *Client) DoWithAppSpan(req *http.Request, name string) (res *http.Respon
zipkin.TagHTTPMethod.Set(appSpan, req.Method)
zipkin.TagHTTPPath.Set(appSpan, req.URL.Path)

res, err = c.Client.Do(
res, err := c.Do(
req.WithContext(zipkin.NewContext(req.Context(), appSpan)),
)
if err != nil {
zipkin.TagError.Set(appSpan, err.Error())
appSpan.Finish()
return
return res, err
}

if c.httpTrace {
Expand Down
14 changes: 5 additions & 9 deletions reporter/amqp/amqp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,15 @@ func TestRabbitClose(t *testing.T) {
}
}

func setupRabbit(t *testing.T, address string) (conn *amqp.Connection, ch *amqp.Channel, close func()) {
func setupRabbit(t *testing.T, address string) (*amqp.Connection, *amqp.Channel, func()) {
var err error
conn, err = amqp.Dial(address)
conn, err := amqp.Dial(address)
failOnError(t, err, "Failed to connect to RabbitMQ")

ch, err = conn.Channel()
ch, err := conn.Channel()
failOnError(t, err, "Failed to open a channel")

close = func() {
conn.Close()
ch.Close()
}
return
return conn, ch, func() { conn.Close(); ch.Close() }
}

func setupConsume(t *testing.T, ch *amqp.Channel) <-chan amqp.Delivery {
Expand Down Expand Up @@ -139,7 +135,7 @@ func testEqual(t *testing.T, want *model.SpanModel, have *model.SpanModel) {

func makeNewSpan(methodName string, traceID, spanID, parentSpanID uint64, debug bool) *model.SpanModel {
timestamp := time.Now()
var parentID = new(model.ID)
parentID := new(model.ID)
if parentSpanID != 0 {
*parentID = model.ID(parentSpanID)
}
Expand Down

0 comments on commit 362ac86

Please sign in to comment.