diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..33ec2f66 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,76 @@ +# https://golangci-lint.run/usage/configuration/ + +linters: + enable-all: true + disable: + - ifshort + - exhaustivestruct + - golint + - nosnakecase + - scopelint + - varcheck + - structcheck + - interfacer + - exhaustivestruct + - maligned + - deadcode + - dogsled + - wrapcheck + - wastedassign + - varnamelen + - testpackage + - thelper + - nilerr + - sqlclosecheck + - paralleltest + - nonamedreturns + - nlreturn + - nakedret + - ireturn + - interfacebloat + - gosmopolitan + - gomnd + - goerr113 + - gochecknoglobals + - exhaustruct + - errorlint + - depguard + - exhaustive + - containedctx + - wsl + - cyclop + - dupword + - errchkjson + - contextcheck + - tagalign + - dupl + - forbidigo + - funlen + - goconst + - godox + - gosec + - lll + - nestif + - revive + - unparam + - stylecheck + - gocritic + - gofumpt + - gomoddirectives + - godot + - gofmt + - gocognit + - mirror + - gocyclo + - gochecknoinits + - gci + - maintidx + - prealloc + - goimports + - errname + - musttag + - forcetypeassert + - whitespace + - noctx + - tagliatelle + - nilnil \ No newline at end of file diff --git a/internal/db/models/sys_locker_dao.go b/internal/db/models/sys_locker_dao.go index 51a053e2..be2ef5fd 100644 --- a/internal/db/models/sys_locker_dao.go +++ b/internal/db/models/sys_locker_dao.go @@ -160,7 +160,7 @@ func (this *SysLockerDAO) Increase(tx *dbs.Tx, key string, defaultValue int64) ( colValue, err := tx.FindCol(0, "INSERT INTO `"+this.Table+"` (`key`, `version`) VALUES ('"+key+"', "+types.String(defaultValue+sysLockerStep)+") ON DUPLICATE KEY UPDATE `version`=`version`+"+types.String(sysLockerStep)+"; SELECT `version` FROM `"+this.Table+"` WHERE `key`='"+key+"'") if err != nil { if CheckSQLErrCode(err, 1064 /** syntax error **/) { - // continue to use seperated query + // continue to use separated query err = nil } else { return 0, err diff --git a/internal/dnsclients/provider_custom_http.go b/internal/dnsclients/provider_custom_http.go index 1de86227..aea2a688 100644 --- a/internal/dnsclients/provider_custom_http.go +++ b/internal/dnsclients/provider_custom_http.go @@ -201,7 +201,7 @@ func (this *CustomHTTPProvider) post(params maps.Map) (respData []byte, err erro defer func() { _ = resp.Body.Close() }() - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return nil, errors.New("status should be 200, but got '" + strconv.Itoa(resp.StatusCode) + "'") } return io.ReadAll(resp.Body) diff --git a/internal/dnsclients/provider_edge_dns_api.go b/internal/dnsclients/provider_edge_dns_api.go index db301065..b7cc3c3b 100644 --- a/internal/dnsclients/provider_edge_dns_api.go +++ b/internal/dnsclients/provider_edge_dns_api.go @@ -435,6 +435,11 @@ func (this *EdgeDNSAPIProvider) doAPI(path string, params map[string]any, respPt if err != nil { return err } + defer func() { + if resp.Body != nil { + _ = resp.Body.Close() + } + }() if resp.StatusCode != http.StatusOK { return errors.New("invalid response status code '" + types.String(resp.StatusCode) + "'") diff --git a/internal/errors/detailed_error.go b/internal/errors/detailed_error.go index d2e12edd..3e6f1522 100644 --- a/internal/errors/detailed_error.go +++ b/internal/errors/detailed_error.go @@ -13,9 +13,9 @@ func (this *DetailedError) Code() string { return this.code } -func NewDetailedError(code string, error string) *DetailedError { +func NewDetailedError(code string, errString string) *DetailedError { return &DetailedError{ - msg: error, + msg: errString, code: code, } }