Skip to content

Commit

Permalink
add flag for printing the version
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
gordonklaus committed Oct 29, 2023
1 parent 0e73809 commit a64629a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ineffassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"go/token"
"log"
"os"
"runtime/debug"
"strings"
"sync"

Expand All @@ -21,6 +22,10 @@ func main() {
log.SetFlags(0)
log.SetPrefix(ineffassign.Analyzer.Name + ": ")

var (
printVersion = flag.Bool("version", false, "print ineffassign version")
_ = flag.Bool("n", false, "no effect (deprecated)")
)
flag.Usage = func() {
paras := strings.Split(ineffassign.Analyzer.Doc, "\n\n")
fmt.Fprintf(os.Stderr, "%s: %s\n\n", ineffassign.Analyzer.Name, paras[0])
Expand All @@ -33,6 +38,12 @@ func main() {
}
flag.Parse()

if *printVersion {
bi, _ := debug.ReadBuildInfo()
log.Print("version ", bi.Main.Version)
return
}

patterns := flag.Args()
if len(patterns) == 0 {
flag.Usage()
Expand Down Expand Up @@ -114,7 +125,3 @@ func load(patterns ...string) ([]*packages.Package, error) {

return pkgs, nil
}

func init() {
flag.Bool("n", false, "no effect (deprecated)")
}

0 comments on commit a64629a

Please sign in to comment.