From 6d0e726fcbd80442f9311c5e4114b2e1e6c9413f Mon Sep 17 00:00:00 2001 From: arrebole Date: Wed, 26 Jul 2023 15:02:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwindows=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E9=80=9A=E9=85=8D=E7=AC=A6=E5=8C=B9=E9=85=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复windows平台通配符匹配问题 * fix: 修复golangci-lint新版本配置 --- .golangci.yml | 15 +++++++++++++-- commands.go | 6 +++++- utils.go | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 393c267..0ddefab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,11 +19,22 @@ linters: - goimports - goprintffuncname - govet - - interfacer - misspell - nolintlint - - scopelint + - exportloopref - typecheck - unconvert - unparam - whitespace + +linters-settings: + depguard: + rules: + main: + allow: + - $gostd + - github.com + test: + allow: + - $gostd + - github.com \ No newline at end of file diff --git a/commands.go b/commands.go index 13cf522..26651d1 100644 --- a/commands.go +++ b/commands.go @@ -368,8 +368,12 @@ func NewUploadCommand() cli.Command { if c.Int("w") > 10 || c.Int("w") < 1 { PrintErrorAndExit("max concurrent threads must between (1 - 10)") } + filenames := c.Args() + if isWindowsGOOS() { + filenames = globFiles(filenames) + } session.Upload( - c.Args(), + filenames, c.String("remote"), c.Int("w"), c.Bool("all"), diff --git a/utils.go b/utils.go index 28d9906..013944e 100644 --- a/utils.go +++ b/utils.go @@ -5,6 +5,8 @@ import ( "fmt" "io" "os" + "path/filepath" + "runtime" "strconv" "strings" "time" @@ -140,3 +142,18 @@ func contains(slice []string, item string) bool { } return false } + +func globFiles(patterns []string) []string { + filenames := make([]string, 0) + for _, filename := range patterns { + matches, err := filepath.Glob(filename) + if err == nil { + filenames = append(filenames, matches...) + } + } + return filenames +} + +func isWindowsGOOS() bool { + return runtime.GOOS == "windows" +}