Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Apr 5, 2024
1 parent d4338b6 commit 47ea3c8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
36 changes: 19 additions & 17 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
run:
modules-download-mode: readonly
skip-dirs:
- .git
- .github
- .vscode
- dist

linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/axiomhq/axiom-syslog-proxy
govet:
enable:
- shadow
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true

linters:
disable-all: true
Expand Down Expand Up @@ -34,15 +42,9 @@ linters:
- unused
- whitespace

linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/axiomhq/axiom-syslog-proxy
govet:
check-shadowing: true
nolintlint:
allow-unused: false
allow-leading-space: false
require-explanation: true
require-specific: true
issues:
exclude-dirs:
- .git
- .github
- .vscode
- dist
6 changes: 3 additions & 3 deletions parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func parseJSON(data []byte) (*Log, error) {
Metadata: map[string]interface{}{},
}

if err := jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
if err := jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, _ int) error {
return extractJSONProperty(key, value, dataType, msg)
}); err != nil {
return nil, err
Expand Down Expand Up @@ -197,15 +197,15 @@ func extractMetadataValue(concatKey string, value []byte, dataType jsonparser.Va
switch dataType {
case jsonparser.Object:
level++
if err := jsonparser.ObjectEach(value, func(kk []byte, vv []byte, dtdt jsonparser.ValueType, offset int) error {
if err := jsonparser.ObjectEach(value, func(kk []byte, vv []byte, dtdt jsonparser.ValueType, _ int) error {
return extractMetadataValue(joinKey(concatKey, string(kk)), vv, dtdt, level, msg)
}); err != nil {
return err
}
case jsonparser.Array:
arrayIndex := 0
level++
if _, err := jsonparser.ArrayEach(value, func(vv []byte, dtdt jsonparser.ValueType, offset int, err error) {
if _, err := jsonparser.ArrayEach(value, func(vv []byte, dtdt jsonparser.ValueType, _ int, err error) {
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func BenchmarkParserDifferentMetadataTypes(b *testing.B) {
}

func BenchmarkParser(b *testing.B) {
p := New(func(msg *Log) {})
p := New(func(_ *Log) {})

const msg = "<1> 2009-10-16T11:51:56+02:00 ip-34-23-211-23 symbolicator ERROR 2008 SOMEMSG - hello"
rawMsg := []byte(msg)
Expand Down
4 changes: 2 additions & 2 deletions parser/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,10 @@ func parseStructuredData(data []byte, index *int, length *int) (map[string]map[s
sc := scanner.Scanner{}
sc.Init(bytes.NewBuffer(data[offset+1:]))
sc.Mode = scanner.ScanStrings | scanner.ScanIdents
sc.IsIdentRune = func(ch rune, i int) bool {
sc.IsIdentRune = func(ch rune, _ int) bool {
return unicode.IsLetter(ch) || unicode.IsDigit(ch) || ch == '@' || ch == '.'
}
sc.Error = func(s *scanner.Scanner, msg string) {}
sc.Error = func(_ *scanner.Scanner, _ string) {}

var (
sdID, sdParam string
Expand Down

0 comments on commit 47ea3c8

Please sign in to comment.