-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.go
50 lines (43 loc) · 1.02 KB
/
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
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2017, Daniel Martí <[email protected]>
// 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.ContinueOnError)
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() {
os.Exit(main1())
}
func main1() int {
flagSet.Usage = func() {
fmt.Fprintln(os.Stderr, "usage: unparam [flags] [package ...]")
flagSet.PrintDefaults()
}
if err := flagSet.Parse(os.Args[1:]); err != nil {
if err != flag.ErrHelp {
fmt.Fprintln(os.Stderr, err)
}
return 1
}
warns, err := check.UnusedParams(*tests, *exported, *debug, flagSet.Args()...)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
}
for _, warn := range warns {
fmt.Println(warn)
}
if len(warns) > 0 {
return 1
}
return 0
}