diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f77aaab..c03c85d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -18,9 +18,9 @@ jobs: check-latest: true - name: Setup golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: - version: latest + version: v2.0 args: --verbose - uses: hadolint/hadolint-action@v3.1.0 diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..c01d3c7 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,54 @@ +version: "2" +linters: + enable: + - asciicheck + - durationcheck + - errorlint + - gosec + - misspell + - nakedret + - nilerr + - nolintlint + - perfsprint + - revive + - usestdlibvars + - wastedassign + settings: + gosec: + includes: + - G102 + - G106 + - G108 + - G109 + - G111 + - G112 + - G201 + - G203 + perfsprint: + int-conversion: true + err-error: true + errorf: true + sprintf1: true + strconcat: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/plugin.go b/plugin.go index eb51b47..5e3faa6 100644 --- a/plugin.go +++ b/plugin.go @@ -234,7 +234,7 @@ func (p *Plugin) Exec() error { return errMissingHost } - p.DestFile = fmt.Sprintf("%s.tar.gz", random.String(10)) + p.DestFile = random.String(10) + ".tar.gz" // create a temporary file for the archive dir := os.TempDir() @@ -310,7 +310,7 @@ func (p *Plugin) Exec() error { } for _, target := range p.Config.Target { - target = strings.Replace(target, " ", "\\ ", -1) + target = strings.ReplaceAll(target, " ", "\\ ") // remove target folder before upload data if p.Config.Remove { p.log(host, "Remove target folder:", target) @@ -376,7 +376,8 @@ func (p *Plugin) Exec() error { if err != nil { c := color.New(color.FgRed) c.Println("drone-scp error: ", err) - if _, ok := err.(copyError); !ok { + var cerr copyError + if !errors.As(err, &cerr) { fmt.Println("drone-scp rollback: remove all target tmp file") if err := p.removeAllDestFile(); err != nil { return err