Skip to content

Commit 3565e35

Browse files
Jack Lindamoodluluzhao
Jack Lindamood
authored andcommitted
Lints (aws#117)
Fix a few lints that are somewhat easier to think about.
1 parent 5281da0 commit 3565e35

16 files changed

+29
-43
lines changed

.golangci.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ linters:
99
- dupl
1010
- errcheck
1111
- gochecknoinits
12-
- goconst
1312
- gocritic
1413
- gocyclo
1514
- gofmt

go.mod

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ module github.com/aws/aws-xray-sdk-go
33
require (
44
github.com/DATA-DOG/go-sqlmock v1.2.0
55
github.com/aws/aws-sdk-go v1.17.12
6-
github.com/davecgh/go-spew v0.0.0-20160907170601-6d212800a42e
7-
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
6+
github.com/davecgh/go-spew v0.0.0-20160907170601-6d212800a42e // indirect
87
github.com/pkg/errors v0.8.1
9-
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0
8+
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 // indirect
109
github.com/stretchr/testify v1.1.4
11-
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95
12-
golang.org/x/text v0.0.0-20190306152657-5d731a35f486
10+
golang.org/x/net v0.0.0-20190311183353-d8887717615a
1311
)

go.sum

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 h1:GD+A8+e+wFkq
1212
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1313
github.com/stretchr/testify v1.1.4 h1:ToftOQTytwshuOSj6bDSolVUa3GINfJP/fg3OkkOzQQ=
1414
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
15-
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95 h1:fY7Dsw114eJN4boqzVSbpVHO6rTdhq6/GnXeu+PKnzU=
16-
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
17-
golang.org/x/text v0.0.0-20190306152657-5d731a35f486 h1:XzEEnDs8NtiSU8gJvzuDjv+Kam+0nPN9pjOA3oZlxIY=
18-
golang.org/x/text v0.0.0-20190306152657-5d731a35f486/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
19-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
15+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
16+
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
17+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
18+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
19+
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
20+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

internal/logger/logger.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/aws/aws-xray-sdk-go/xraylog"
1616
)
1717

18-
// This internal pacakge hides the actual logging functions from the user.
18+
// This internal package hides the actual logging functions from the user.
1919

2020
// The Logger instance used by xray to log. Set via xray.SetLogger().
2121
var Logger xraylog.Logger = xraylog.NewDefaultLogger(os.Stdout, xraylog.LogLevelInfo)

resources/bindata.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

strategy/sampling/centralized_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ func TestRefreshManifestRuleAddition(t *testing.T) {
966966
assert.Equal(t, r2, ss.manifest.Rules[1])
967967
assert.Equal(t, r3, ss.manifest.Rules[2])
968968

969-
// Assert on size of manfiest
969+
// Assert on size of manifest
970970
assert.Equal(t, 3, len(ss.manifest.Rules))
971971
assert.Equal(t, 3, len(ss.manifest.Index))
972972

xray/aws.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,6 @@ var xRayBeforeSignHandler = request.NamedHandler{
8787
},
8888
}
8989

90-
var xRayAfterSignHandler = request.NamedHandler{
91-
Name: "XRayAfterSignHandler",
92-
Fn: func(r *request.Request) {
93-
endSubsegment(r)
94-
},
95-
}
96-
97-
var xRayBeforeSendHandler = request.NamedHandler{
98-
Name: "XRayBeforeSendHandler",
99-
Fn: func(r *request.Request) {
100-
},
101-
}
102-
10390
var xRayAfterSendHandler = request.NamedHandler{
10491
Name: "XRayAfterSendHandler",
10592
Fn: func(r *request.Request) {
@@ -287,8 +274,7 @@ func (j *jsonMap) data() interface{} {
287274
}
288275

289276
func (j *jsonMap) search(keys ...string) *jsonMap {
290-
var object interface{}
291-
object = j.data()
277+
object := j.data()
292278

293279
for target := 0; target < len(keys); target++ {
294280
if mmap, ok := object.(map[string]interface{}); ok {

xray/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (te *TestEmitter) Emit(seg *Segment) {}
7272
func (te *TestEmitter) RefreshEmitterWithAddress(raddr *net.UDPAddr) {}
7373

7474
func (cms *TestContextMissingStrategy) ContextMissing(v interface{}) {
75-
fmt.Sprintf("Test ContextMissing Strategy %v", v)
75+
fmt.Printf("Test ContextMissing Strategy %v\n", v)
7676
}
7777

7878
func stashEnv() []string {

xray/default_emitter_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ package xray
1111
import (
1212
"encoding/json"
1313
"fmt"
14-
"github.com/stretchr/testify/assert"
1514
"math/rand"
1615
"testing"
1716
"time"
17+
18+
"github.com/stretchr/testify/assert"
1819
)
1920

2021
func TestNoNeedStreamingStrategy(t *testing.T) {

xray/default_streaming_strategy_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
package xray
1010

1111
import (
12-
"github.com/stretchr/testify/assert"
1312
"testing"
13+
14+
"github.com/stretchr/testify/assert"
1415
)
1516

1617
func TestDefaultStreamingStrategyMaxSegmentSize(t *testing.T) {

xray/lambda_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package xray
22

33
import (
44
"context"
5-
"github.com/stretchr/testify/assert"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func TestLambdaSegmentEmit(t *testing.T) {

xray/segment.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func BeginSubsegment(ctx context.Context, name string) (context.Context, *Segmen
162162
name = name[:200]
163163
}
164164

165-
parent := &Segment{}
165+
var parent *Segment
166166
// first time to create facade segment
167167
if getTraceHeaderFromContext(ctx) != nil && GetSegment(ctx) == nil {
168168
_, parent = newFacadeSegment(ctx)
@@ -445,10 +445,8 @@ func (seg *Segment) AddError(err error) error {
445445
return nil
446446
}
447447

448-
func (seg *Segment) addError(err error) error {
448+
func (seg *Segment) addError(err error) {
449449
seg.Fault = true
450450
seg.GetCause().WorkingDirectory, _ = os.Getwd()
451451
seg.GetCause().Exceptions = append(seg.GetCause().Exceptions, seg.ParentSegment.GetConfiguration().ExceptionFormattingStrategy.ExceptionFromError(err))
452-
453-
return nil
454452
}

xray/segment_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestSubsegmentDataRace(t *testing.T) {
3939
go func() {
4040
defer wg.Done()
4141
ctx, seg := BeginSubsegment(ctx, "TestSubsegment1")
42-
ctx, seg2 := BeginSubsegment(ctx, "TestSubsegment2")
42+
_, seg2 := BeginSubsegment(ctx, "TestSubsegment2")
4343
seg2.Close(nil)
4444
seg.Close(nil)
4545
}()

xray/sql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,4 @@ func processNilSegment(ctx context.Context) {
295295
} else {
296296
globalCfg.ContextMissingStrategy().ContextMissing(failedMessage)
297297
}
298-
}
298+
}

xray/util_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ package xray
1111
import (
1212
"context"
1313
"encoding/json"
14-
"github.com/aws/aws-xray-sdk-go/header"
1514
"net"
1615
"net/http"
1716
"time"
17+
18+
"github.com/aws/aws-xray-sdk-go/header"
1819
)
1920

2021
var (

xraylog/xray_log.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func NewDefaultLogger(w io.Writer, minLogLevel LogLevel) Logger {
6161
}
6262

6363
type defaultLogger struct {
64-
mu sync.Mutex
64+
mu sync.Mutex
6565
w io.Writer
6666
minLevel LogLevel
6767
}

0 commit comments

Comments
 (0)