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/helpers"
|
||||||
"github.com/cloudflare/cfssl/revoke"
|
"github.com/cloudflare/cfssl/revoke"
|
||||||
"github.com/kisom/die"
|
"github.com/kisom/goutils/die"
|
||||||
"github.com/kisom/goutils/lib"
|
"github.com/kisom/goutils/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/kisom/die"
|
"github.com/kisom/goutils/die"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/kisom/die"
|
"github.com/kisom/goutils/die"
|
||||||
)
|
)
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
|
|
|
@ -19,14 +19,29 @@ import (
|
||||||
var (
|
var (
|
||||||
gopath string
|
gopath string
|
||||||
project string
|
project string
|
||||||
|
debug bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
stdLibRegexp = regexp.MustCompile(`^\w+(/\w+)*$`)
|
stdLibRegexp = regexp.MustCompile(`^\w+(/\w+)*$`)
|
||||||
sourceRegexp = regexp.MustCompile(`^[^.].*\.go$`)
|
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() {
|
func init() {
|
||||||
gopath = os.Getenv("GOPATH")
|
gopath = os.Getenv("GOPATH")
|
||||||
if gopath == "" {
|
if gopath == "" {
|
||||||
|
@ -51,17 +66,12 @@ func init() {
|
||||||
project = wd[len(gopath):]
|
project = wd[len(gopath):]
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
imports = map[string]bool{}
|
|
||||||
fset = &token.FileSet{}
|
|
||||||
)
|
|
||||||
|
|
||||||
func walkFile(path string, info os.FileInfo, err error) error {
|
func walkFile(path string, info os.FileInfo, err error) error {
|
||||||
if !sourceRegexp.MatchString(path) {
|
if !sourceRegexp.MatchString(path) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(path)
|
debugln(path)
|
||||||
|
|
||||||
f, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
|
f, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -71,16 +81,16 @@ func walkFile(path string, info os.FileInfo, err error) error {
|
||||||
for _, importSpec := range f.Imports {
|
for _, importSpec := range f.Imports {
|
||||||
importPath := strings.Trim(importSpec.Path.Value, `"`)
|
importPath := strings.Trim(importSpec.Path.Value, `"`)
|
||||||
if stdLibRegexp.MatchString(importPath) {
|
if stdLibRegexp.MatchString(importPath) {
|
||||||
log.Debug("standard lib:", importPath)
|
debugln("standard lib:", importPath)
|
||||||
continue
|
continue
|
||||||
} else if strings.HasPrefix(importPath, project) {
|
} else if strings.HasPrefix(importPath, project) {
|
||||||
log.Debug("internal import:", importPath)
|
debugln("internal import:", importPath)
|
||||||
continue
|
continue
|
||||||
} else if strings.HasPrefix(importPath, "golang.org/") {
|
} else if strings.HasPrefix(importPath, "golang.org/") {
|
||||||
log.Debug("extended lib:", importPath)
|
debugln("extended lib:", importPath)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Debug("import:", importPath)
|
debugln("import:", importPath)
|
||||||
imports[importPath] = true
|
imports[importPath] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +98,9 @@ func walkFile(path string, info os.FileInfo, err error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
verbose := flag.Bool("v", false, "log debugging information")
|
flag.BoolVar(&debug, "v", false, "log debugging information")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *verbose {
|
|
||||||
log.SetLevel(logging.LevelDebug)
|
|
||||||
}
|
|
||||||
err := filepath.Walk(".", walkFile)
|
err := filepath.Walk(".", walkFile)
|
||||||
die.If(err)
|
die.If(err)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/kisom/die"
|
"github.com/kisom/goutils/die"
|
||||||
)
|
)
|
||||||
|
|
||||||
var validPEMs = map[string]bool{
|
var validPEMs = map[string]bool{
|
||||||
|
|
Loading…
Reference in New Issue