Sha256: 551ca6be799d62d43f82f526f3150be24c330a861e133db69bdb8d1c1e301060
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
// Copyright (c) 2013 The Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd. // golint lints the Go source files named on its command line. package main import ( "flag" "fmt" "io/ioutil" "os" "path/filepath" "strings" "github.com/golang/lint" ) var minConfidence = flag.Float64("min_confidence", 0.8, "minimum confidence of a problem to print it") func main() { flag.Parse() for _, filename := range flag.Args() { if isDir(filename) { lintDir(filename) } else { lintFile(filename) } } } func isDir(filename string) bool { fi, err := os.Stat(filename) return err == nil && fi.IsDir() } func lintFile(filename string) { src, err := ioutil.ReadFile(filename) if err != nil { fmt.Fprintln(os.Stderr, err) return } l := new(lint.Linter) ps, err := l.Lint(filename, src) if err != nil { fmt.Fprintf(os.Stderr, "%v:%v\n", filename, err) return } for _, p := range ps { if p.Confidence >= *minConfidence { fmt.Printf("%s:%v: %s\n", filename, p.Position, p.Text) } } } func lintDir(dirname string) { filepath.Walk(dirname, func(path string, info os.FileInfo, err error) error { if err == nil && !info.IsDir() && strings.HasSuffix(path, ".go") { lintFile(path) } return err }) }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exercism-analysis-0.1.1 | vendor/go/src/github.com/golang/lint/golint/golint.go |