Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors #63

Merged
merged 1 commit into from Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 19 additions & 17 deletions .golangci.yaml
@@ -1,10 +1,18 @@
run:
modules-download-mode: readonly
skip-dirs:
lukasmalkmus marked this conversation as resolved.
Show resolved Hide resolved
- .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
lukasmalkmus marked this conversation as resolved.
Show resolved Hide resolved
nolintlint:
allow-unused: false
allow-leading-space: false
lukasmalkmus marked this conversation as resolved.
Show resolved Hide resolved
require-explanation: true
require-specific: true
issues:
exclude-dirs:
- .git
- .github
- .vscode
- dist
6 changes: 3 additions & 3 deletions parser/parse.go
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
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
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