Skip to content

Commit

Permalink
fix: 修复windows平台通配符匹配问题 (#96)
Browse files Browse the repository at this point in the history
* fix: 修复windows平台通配符匹配问题

* fix: 修复golangci-lint新版本配置
  • Loading branch information
arrebole authored Jul 26, 2023
1 parent 75b02db commit 6d0e726
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
15 changes: 13 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
17 changes: 17 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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"
}

0 comments on commit 6d0e726

Please sign in to comment.