-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.go
40 lines (34 loc) · 897 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2017, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
// unparam reports unused function parameters and results in your code.
package main
import (
"flag"
"fmt"
"os"
"mvdan.cc/unparam/check"
)
var (
flagSet = flag.NewFlagSet("unparam", flag.ExitOnError)
tests = flagSet.Bool("tests", false, "load tests too")
exported = flagSet.Bool("exported", false, "inspect exported functions")
debug = flagSet.Bool("debug", false, "debug prints")
)
func main() {
flagSet.Usage = func() {
fmt.Fprintln(os.Stderr, "usage: unparam [flags] [package ...]")
flagSet.PrintDefaults()
}
flagSet.Parse(os.Args[1:])
warns, err := check.UnusedParams(*tests, *exported, *debug, flagSet.Args()...)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
for _, warn := range warns {
fmt.Println(warn)
}
if len(warns) > 0 {
os.Exit(1)
}
}