~sircmpwn/annotatego

e52c42dbbe89fcf4f615762423ba6dc347f333c0 — Drew DeVault 6 months ago 18fe93f master
Switch to less broken getopt implementation
1 files changed, 14 insertions(+), 10 deletions(-)

M main.go
M main.go => main.go +14 -10
@@ 110,20 110,24 @@ func godocUrl(object types.Object) string {
}

func main() {
	opts, optind, err := getopt.Getopts(os.Args, "Tdv")
	if err != nil {
		log.Fatalf("getopt: ", err)
	}
	var (
		disableGodoc bool
		enableTests  bool
		enableVars   bool
	)
	getopt.BoolVar(&enableVars, "-v", false,
		"Enables linking of variables to their declarations")
	getopt.BoolVar(&disableGodoc, "-d", false,
		"Disables linking to external symbols via Godoc")
	getopt.BoolVar(&enableTests, "-T", false,
		"Enables scanning of test files as well as normal code")
	err := getopt.Parse()
	if err != nil {
		log.Fatalf("getopt: ", err)
	for _, opt := range opts {
		switch opt.Option {
		case 'T':
			enableTests = true
		case 'd':
			disableGodoc = true
		case 'v':
			enableVars = true
		}
	}

	log.SetFlags(0)


@@ 139,7 143,7 @@ func main() {
			packages.NeedDeps |
			packages.NeedImports),
	}
	pkgs, err := packages.Load(&conf, getopt.Args()...)
	pkgs, err := packages.Load(&conf, os.Args[optind:]...)
	if err != nil {
		log.Fatal(err)
	}