From 5832af1e8e96815cc88e965eac13c32926d200da Mon Sep 17 00:00:00 2001 From: kianaza Date: Mon, 20 May 2024 18:50:58 +0330 Subject: [PATCH] feat: Simplify linter configuration and fix related issues --- .github/workflows/ci.yaml | 13 ++++++++----- .golangci.yml | 7 ++++++- internal/cmd/main.go | 4 ++-- internal/config/config.go | 4 ++-- internal/config/default.go | 4 ++-- internal/natsClient/client.go | 2 +- internal/natsClient/config.go | 2 +- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7079c7f..f9a82a9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,11 +7,14 @@ name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - version: latest + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.20' + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58 test: name: test runs-on: ubuntu-latest diff --git a/.golangci.yml b/.golangci.yml index 45839d5..a674881 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,8 @@ --- linters: - disable-all: true + enable: + - gofmt + - govet + - revive + - staticcheck + - errcheck \ No newline at end of file diff --git a/internal/cmd/main.go b/internal/cmd/main.go index 4a56b35..eb60349 100644 --- a/internal/cmd/main.go +++ b/internal/cmd/main.go @@ -6,14 +6,14 @@ import ( "syscall" "github.com/snapp-incubator/nats-blackbox-exporter/internal/config" - "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsClient" + "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsclient" "go.uber.org/zap" ) func main(cfg config.Config, logger *zap.Logger) { natsConfig := cfg.NATS - client := natsClient.New(natsClient.Connect(logger, natsConfig), logger, natsConfig) + client := natsclient.New(natsclient.Connect(logger, natsConfig), logger, natsConfig) client.StartMessaging() diff --git a/internal/config/config.go b/internal/config/config.go index 7f3f031..ae5b09b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,7 +11,7 @@ import ( "github.com/knadh/koanf/providers/structs" "github.com/knadh/koanf/v2" "github.com/snapp-incubator/nats-blackbox-exporter/internal/logger" - "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsClient" + "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsclient" "github.com/tidwall/pretty" ) @@ -24,7 +24,7 @@ type ( // Config holds all configurations. Config struct { Logger logger.Config `json:"logger,omitempty" koanf:"logger"` - NATS natsClient.Config `json:"nats,omitempty" koanf:"nats"` + NATS natsclient.Config `json:"nats,omitempty" koanf:"nats"` } ) diff --git a/internal/config/default.go b/internal/config/default.go index a66a123..3924ee3 100644 --- a/internal/config/default.go +++ b/internal/config/default.go @@ -4,7 +4,7 @@ import ( "time" "github.com/snapp-incubator/nats-blackbox-exporter/internal/logger" - "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsClient" + "github.com/snapp-incubator/nats-blackbox-exporter/internal/natsclient" ) // Default return default configuration. @@ -14,7 +14,7 @@ func Default() Config { Logger: logger.Config{ Level: "debug", }, - NATS: natsClient.Config{ + NATS: natsclient.Config{ URL: "localhost:4222", PublishInterval: 2 * time.Second, RequestTimeout: 50 * time.Millisecond, diff --git a/internal/natsClient/client.go b/internal/natsClient/client.go index c1f3823..de3a5e5 100644 --- a/internal/natsClient/client.go +++ b/internal/natsClient/client.go @@ -1,4 +1,4 @@ -package natsClient +package natsclient import ( "time" diff --git a/internal/natsClient/config.go b/internal/natsClient/config.go index dc9bd29..357d69e 100644 --- a/internal/natsClient/config.go +++ b/internal/natsClient/config.go @@ -1,4 +1,4 @@ -package natsClient +package natsclient import "time"