Use goutils/die instead of kisom/die.
Also removes the "logging" package from showimp, as this is intended primarily for server programs.
This commit is contained in:
parent
8055404211
commit
1650edee19
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/cloudflare/cfssl/helpers"
|
||||
"github.com/cloudflare/cfssl/revoke"
|
||||
"github.com/kisom/die"
|
||||
"github.com/kisom/goutils/die"
|
||||
"github.com/kisom/goutils/lib"
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"github.com/kisom/die"
|
||||
"github.com/kisom/goutils/die"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/kisom/die"
|
||||
"github.com/kisom/goutils/die"
|
||||
)
|
||||
|
||||
func usage() {
|
||||
|
|
|
@ -19,14 +19,29 @@ import (
|
|||
var (
|
||||
gopath string
|
||||
project string
|
||||
debug bool
|
||||
)
|
||||
|
||||
var (
|
||||
stdLibRegexp = regexp.MustCompile(`^\w+(/\w+)*$`)
|
||||
sourceRegexp = regexp.MustCompile(`^[^.].*\.go$`)
|
||||
log = logging.Init()
|
||||
log = logging.NewConsole()
|
||||
imports = map[string]bool{}
|
||||
fset = &token.FileSet{}
|
||||
)
|
||||
|
||||
func debugf(format string, args ...interface{}) {
|
||||
if debug {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func debugln(args ...interface{}) {
|
||||
if debug {
|
||||
fmt.Println(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
gopath = os.Getenv("GOPATH")
|
||||
if gopath == "" {
|
||||
|
@ -51,17 +66,12 @@ func init() {
|
|||
project = wd[len(gopath):]
|
||||
}
|
||||
|
||||
var (
|
||||
imports = map[string]bool{}
|
||||
fset = &token.FileSet{}
|
||||
)
|
||||
|
||||
func walkFile(path string, info os.FileInfo, err error) error {
|
||||
if !sourceRegexp.MatchString(path) {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debug(path)
|
||||
debugln(path)
|
||||
|
||||
f, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
|
||||
if err != nil {
|
||||
|
@ -71,16 +81,16 @@ func walkFile(path string, info os.FileInfo, err error) error {
|
|||
for _, importSpec := range f.Imports {
|
||||
importPath := strings.Trim(importSpec.Path.Value, `"`)
|
||||
if stdLibRegexp.MatchString(importPath) {
|
||||
log.Debug("standard lib:", importPath)
|
||||
debugln("standard lib:", importPath)
|
||||
continue
|
||||
} else if strings.HasPrefix(importPath, project) {
|
||||
log.Debug("internal import:", importPath)
|
||||
debugln("internal import:", importPath)
|
||||
continue
|
||||
} else if strings.HasPrefix(importPath, "golang.org/") {
|
||||
log.Debug("extended lib:", importPath)
|
||||
debugln("extended lib:", importPath)
|
||||
continue
|
||||
}
|
||||
log.Debug("import:", importPath)
|
||||
debugln("import:", importPath)
|
||||
imports[importPath] = true
|
||||
}
|
||||
|
||||
|
@ -88,12 +98,9 @@ func walkFile(path string, info os.FileInfo, err error) error {
|
|||
}
|
||||
|
||||
func main() {
|
||||
verbose := flag.Bool("v", false, "log debugging information")
|
||||
flag.BoolVar(&debug, "v", false, "log debugging information")
|
||||
flag.Parse()
|
||||
|
||||
if *verbose {
|
||||
log.SetLevel(logging.LevelDebug)
|
||||
}
|
||||
err := filepath.Walk(".", walkFile)
|
||||
die.If(err)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/kisom/die"
|
||||
"github.com/kisom/goutils/die"
|
||||
)
|
||||
|
||||
var validPEMs = map[string]bool{
|
||||
|
|
Loading…
Reference in New Issue