github.com/pankona/gometalinter@v2.0.11+incompatible/_linters/src/4d63.com/gochecknoinits/main.go (about)

     1  package main // import "4d63.com/gochecknoinits"
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"os"
     7  )
     8  
     9  func main() {
    10  	flagPrintHelp := flag.Bool("help", false, "")
    11  	flag.Usage = func() {
    12  		fmt.Fprintf(os.Stderr, "Usage: gochecknoinits [path] [path] ...\n")
    13  	}
    14  	flag.Parse()
    15  
    16  	if *flagPrintHelp {
    17  		flag.Usage()
    18  		return
    19  	}
    20  
    21  	paths := flag.Args()
    22  	if len(paths) == 0 {
    23  		paths = []string{"./..."}
    24  	}
    25  
    26  	exitWithError := false
    27  
    28  	for _, path := range paths {
    29  		messages, err := checkNoInits(path)
    30  		for _, message := range messages {
    31  			fmt.Fprintf(os.Stdout, "%s\n", message)
    32  			exitWithError = true
    33  		}
    34  		if err != nil {
    35  			fmt.Fprintf(os.Stderr, "error: %s\n", err)
    36  			exitWithError = true
    37  		}
    38  	}
    39  
    40  	if exitWithError {
    41  		os.Exit(1)
    42  	}
    43  }