mirror of
https://github.com/mgechev/revive.git
synced 2025-05-13 21:46:43 +02:00
Renaming
This commit is contained in:
parent
2ff1cccfd2
commit
eae264645b
46
config.go
46
config.go
@ -7,7 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
zglob "github.com/mattn/go-zglob"
|
"github.com/mgechev/dots"
|
||||||
|
|
||||||
"github.com/mgechev/revive/formatter"
|
"github.com/mgechev/revive/formatter"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
@ -147,47 +148,16 @@ func getFiles() []string {
|
|||||||
fail("files not specified")
|
fail("files not specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches []string
|
files, err := dots.Resolve(globs, strings.Split(excludePaths, " "))
|
||||||
for _, g := range globs {
|
if err != nil {
|
||||||
m, err := zglob.Glob(g)
|
fail(err.Error())
|
||||||
if err != nil {
|
|
||||||
fail(err.Error())
|
|
||||||
}
|
|
||||||
for _, f := range m {
|
|
||||||
if strings.HasSuffix(f, ".go") {
|
|
||||||
matches = append(matches, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if excludeGlobs == "" {
|
return files
|
||||||
return matches
|
|
||||||
}
|
|
||||||
|
|
||||||
excluded := map[string]bool{}
|
|
||||||
excludeGlobSlice := strings.Split(excludeGlobs, " ")
|
|
||||||
for _, g := range excludeGlobSlice {
|
|
||||||
m, err := zglob.Glob(g)
|
|
||||||
if err != nil {
|
|
||||||
fail("error while parsing glob from exclude " + err.Error())
|
|
||||||
}
|
|
||||||
for _, match := range m {
|
|
||||||
excluded[match] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var finalMatches []string
|
|
||||||
for _, m := range matches {
|
|
||||||
if _, ok := excluded[m]; !ok {
|
|
||||||
finalMatches = append(finalMatches, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalMatches
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var configPath string
|
var configPath string
|
||||||
var excludeGlobs string
|
var excludePaths string
|
||||||
var formatterName string
|
var formatterName string
|
||||||
var help bool
|
var help bool
|
||||||
|
|
||||||
@ -204,7 +174,7 @@ func init() {
|
|||||||
formatterUsage = "formatter to be used for the output"
|
formatterUsage = "formatter to be used for the output"
|
||||||
)
|
)
|
||||||
flag.StringVar(&configPath, "config", "", configUsage)
|
flag.StringVar(&configPath, "config", "", configUsage)
|
||||||
flag.StringVar(&excludeGlobs, "exclude", "", excludeUsage)
|
flag.StringVar(&excludePaths, "exclude", "", excludeUsage)
|
||||||
flag.StringVar(&formatterName, "formatter", "", formatterUsage)
|
flag.StringVar(&formatterName, "formatter", "", formatterUsage)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user