From 7e8f07a958d4ca328314e2565f9de91ca4296a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 28 Aug 2023 10:55:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dlint=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 42 ++++++++++++++++++++++++++++++++--------- internal/watch/utils.go | 6 +++--- internal/watch/watch.go | 2 +- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 50a981e..b229b57 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,10 +1,5 @@ -linters-settings: - golint: - min-confidence: 0 - misspell: - locale: US linters: - disable-all: true + disable-all: false enable: - typecheck - goimports @@ -12,10 +7,39 @@ linters: - govet - ineffassign - gosimple - - deadcode - - structcheck - unused - errcheck + - staticcheck + - gofmt + - bodyclose + - loggercheck + - nilerr + - prealloc + - predeclared + - durationcheck + - makezero + - exportloopref + - rowserrcheck + - stylecheck + - gosec + - nolintlint run: - timeout: 5m + timeout: 10m + +linters-settings: + stylecheck: + checks: ["-ST1003"] + gosec: + excludes: + - G306 + - G401 + - G402 + - G404 + - G501 + - G505 + golint: + min-confidence: 0 + misspell: + locale: US + diff --git a/internal/watch/utils.go b/internal/watch/utils.go index 5dd7c9e..847473c 100644 --- a/internal/watch/utils.go +++ b/internal/watch/utils.go @@ -9,11 +9,11 @@ import ( "go.uber.org/zap" ) -func (w *watch) queryRecord(value string) (*dnspod.RecordListItem, error) { +func (w *watch) queryRecord(domain, name, value string) (*dnspod.RecordListItem, error) { // 实例化一个请求对象,每个接口都会对应一个request对象 request := dnspod.NewDescribeRecordListRequest() - request.Domain = common.StringPtr(w.config.Domain) + request.Domain = common.StringPtr(domain) response, err := w.client.DescribeRecordList(request) if err != nil { @@ -21,7 +21,7 @@ func (w *watch) queryRecord(value string) (*dnspod.RecordListItem, error) { return nil, err } for _, v := range response.Response.RecordList { - if *v.Name == w.config.Name && *v.Value == value { + if *v.Name == name && *v.Value == value { logger.Default().Info("record found", zap.Any("record", v)) return v, nil } diff --git a/internal/watch/watch.go b/internal/watch/watch.go index a3a084c..48328a0 100644 --- a/internal/watch/watch.go +++ b/internal/watch/watch.go @@ -58,7 +58,7 @@ func (w *watch) Start(ctx context.Context, cfg *configs.Config) error { } for _, c := range w.config.CheckDomain { for _, v := range c.Value { - r, err := w.queryRecord(v) + r, err := w.queryRecord(c.Domain, c.Name, v) if err != nil { return err }