Skip to content

Commit

Permalink
Lints (#117)
Browse files Browse the repository at this point in the history
Fix a few lints that are somewhat easier to think about.
  • Loading branch information
Jack Lindamood authored and luluzhao committed Jun 11, 2019
1 parent 5281da0 commit 3565e35
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 43 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Expand Up @@ -9,7 +9,6 @@ linters:
- dupl
- errcheck
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Expand Up @@ -3,11 +3,9 @@ module github.com/aws/aws-xray-sdk-go
require (
github.com/DATA-DOG/go-sqlmock v1.2.0
github.com/aws/aws-sdk-go v1.17.12
github.com/davecgh/go-spew v0.0.0-20160907170601-6d212800a42e
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
github.com/davecgh/go-spew v0.0.0-20160907170601-6d212800a42e // indirect
github.com/pkg/errors v0.8.1
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 // indirect
github.com/stretchr/testify v1.1.4
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95
golang.org/x/text v0.0.0-20190306152657-5d731a35f486
golang.org/x/net v0.0.0-20190311183353-d8887717615a
)
11 changes: 6 additions & 5 deletions go.sum
Expand Up @@ -12,8 +12,9 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 h1:GD+A8+e+wFkq
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.1.4 h1:ToftOQTytwshuOSj6bDSolVUa3GINfJP/fg3OkkOzQQ=
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95 h1:fY7Dsw114eJN4boqzVSbpVHO6rTdhq6/GnXeu+PKnzU=
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/text v0.0.0-20190306152657-5d731a35f486 h1:XzEEnDs8NtiSU8gJvzuDjv+Kam+0nPN9pjOA3oZlxIY=
golang.org/x/text v0.0.0-20190306152657-5d731a35f486/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/aws/aws-xray-sdk-go/xraylog"
)

// This internal pacakge hides the actual logging functions from the user.
// This internal package hides the actual logging functions from the user.

// The Logger instance used by xray to log. Set via xray.SetLogger().
var Logger xraylog.Logger = xraylog.NewDefaultLogger(os.Stdout, xraylog.LogLevelInfo)
Expand Down
6 changes: 3 additions & 3 deletions resources/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion strategy/sampling/centralized_test.go
Expand Up @@ -966,7 +966,7 @@ func TestRefreshManifestRuleAddition(t *testing.T) {
assert.Equal(t, r2, ss.manifest.Rules[1])
assert.Equal(t, r3, ss.manifest.Rules[2])

// Assert on size of manfiest
// Assert on size of manifest
assert.Equal(t, 3, len(ss.manifest.Rules))
assert.Equal(t, 3, len(ss.manifest.Index))

Expand Down
16 changes: 1 addition & 15 deletions xray/aws.go
Expand Up @@ -87,19 +87,6 @@ var xRayBeforeSignHandler = request.NamedHandler{
},
}

var xRayAfterSignHandler = request.NamedHandler{
Name: "XRayAfterSignHandler",
Fn: func(r *request.Request) {
endSubsegment(r)
},
}

var xRayBeforeSendHandler = request.NamedHandler{
Name: "XRayBeforeSendHandler",
Fn: func(r *request.Request) {
},
}

var xRayAfterSendHandler = request.NamedHandler{
Name: "XRayAfterSendHandler",
Fn: func(r *request.Request) {
Expand Down Expand Up @@ -287,8 +274,7 @@ func (j *jsonMap) data() interface{} {
}

func (j *jsonMap) search(keys ...string) *jsonMap {
var object interface{}
object = j.data()
object := j.data()

for target := 0; target < len(keys); target++ {
if mmap, ok := object.(map[string]interface{}); ok {
Expand Down
2 changes: 1 addition & 1 deletion xray/config_test.go
Expand Up @@ -72,7 +72,7 @@ func (te *TestEmitter) Emit(seg *Segment) {}
func (te *TestEmitter) RefreshEmitterWithAddress(raddr *net.UDPAddr) {}

func (cms *TestContextMissingStrategy) ContextMissing(v interface{}) {
fmt.Sprintf("Test ContextMissing Strategy %v", v)
fmt.Printf("Test ContextMissing Strategy %v\n", v)
}

func stashEnv() []string {
Expand Down
3 changes: 2 additions & 1 deletion xray/default_emitter_test.go
Expand Up @@ -11,10 +11,11 @@ package xray
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"math/rand"
"testing"
"time"

"github.com/stretchr/testify/assert"
)

func TestNoNeedStreamingStrategy(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion xray/default_streaming_strategy_test.go
Expand Up @@ -9,8 +9,9 @@
package xray

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDefaultStreamingStrategyMaxSegmentSize(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion xray/lambda_test.go
Expand Up @@ -2,8 +2,9 @@ package xray

import (
"context"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestLambdaSegmentEmit(t *testing.T) {
Expand Down
6 changes: 2 additions & 4 deletions xray/segment.go
Expand Up @@ -162,7 +162,7 @@ func BeginSubsegment(ctx context.Context, name string) (context.Context, *Segmen
name = name[:200]
}

parent := &Segment{}
var parent *Segment
// first time to create facade segment
if getTraceHeaderFromContext(ctx) != nil && GetSegment(ctx) == nil {
_, parent = newFacadeSegment(ctx)
Expand Down Expand Up @@ -445,10 +445,8 @@ func (seg *Segment) AddError(err error) error {
return nil
}

func (seg *Segment) addError(err error) error {
func (seg *Segment) addError(err error) {
seg.Fault = true
seg.GetCause().WorkingDirectory, _ = os.Getwd()
seg.GetCause().Exceptions = append(seg.GetCause().Exceptions, seg.ParentSegment.GetConfiguration().ExceptionFormattingStrategy.ExceptionFromError(err))

return nil
}
2 changes: 1 addition & 1 deletion xray/segment_test.go
Expand Up @@ -39,7 +39,7 @@ func TestSubsegmentDataRace(t *testing.T) {
go func() {
defer wg.Done()
ctx, seg := BeginSubsegment(ctx, "TestSubsegment1")
ctx, seg2 := BeginSubsegment(ctx, "TestSubsegment2")
_, seg2 := BeginSubsegment(ctx, "TestSubsegment2")
seg2.Close(nil)
seg.Close(nil)
}()
Expand Down
2 changes: 1 addition & 1 deletion xray/sql.go
Expand Up @@ -295,4 +295,4 @@ func processNilSegment(ctx context.Context) {
} else {
globalCfg.ContextMissingStrategy().ContextMissing(failedMessage)
}
}
}
3 changes: 2 additions & 1 deletion xray/util_test.go
Expand Up @@ -11,10 +11,11 @@ package xray
import (
"context"
"encoding/json"
"github.com/aws/aws-xray-sdk-go/header"
"net"
"net/http"
"time"

"github.com/aws/aws-xray-sdk-go/header"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion xraylog/xray_log.go
Expand Up @@ -61,7 +61,7 @@ func NewDefaultLogger(w io.Writer, minLogLevel LogLevel) Logger {
}

type defaultLogger struct {
mu sync.Mutex
mu sync.Mutex
w io.Writer
minLevel LogLevel
}
Expand Down

0 comments on commit 3565e35

Please sign in to comment.