Skip to content

Commit

Permalink
refactor(sumologicexporter): use golang.org/x/exp/slices for sorting …
Browse files Browse the repository at this point in the history
…fields (SumoLogic#519)

* refactor(sumologicexporter): use golang.org/x/exp/slices for sorting fields

* chore: adjust golangci-lint config to account for problems with generic code
  • Loading branch information
pmalek authored Apr 5, 2022
1 parent 0d04aeb commit 8137956
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
16 changes: 10 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@ linters-settings:
tab-width: 8

linters:
disable-all: false
disable-all: true
enable:
- gofmt
- deadcode
- unused
- errcheck
- goimports
- misspell
- noctx
- lll
disable:
- maligned
- prealloc
fast: false
- govet
- ineffassign
- structcheck
- typecheck
- varcheck
# These linters are problematic when using go1.18 and generic code like in golang.org/x/exp/slices
# - unused
# - gosimple
# - staticcheck

issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
Expand Down
4 changes: 2 additions & 2 deletions pkg/exporter/sumologicexporter/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package sumologicexporter

import (
"sort"
"strings"

"github.com/google/go-cmp/cmp"
"go.opentelemetry.io/collector/model/pdata"
"golang.org/x/exp/slices"
)

// fields represents metadata
Expand Down Expand Up @@ -80,7 +80,7 @@ func (f fields) string() string {
)
return true
})
sort.Strings(returnValue)
slices.Sort(returnValue)

return strings.Join(returnValue, ", ")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/exporter/sumologicexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
go.opentelemetry.io/collector/model v0.47.0
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/exp v0.0.0-20220328175248-053ad81199eb
)

require (
Expand Down
2 changes: 2 additions & 0 deletions pkg/exporter/sumologicexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20220328175248-053ad81199eb h1:pC9Okm6BVmxEw76PUu0XUbOTQ92JX11hfvqTjAV3qxM=
golang.org/x/exp v0.0.0-20220328175248-053ad81199eb/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down

0 comments on commit 8137956

Please sign in to comment.