Move flag parsing out of init block

For whatever reason it wasn't working for me...
This commit is contained in:
Justin Santa Barbara 2018-09-14 10:40:04 -04:00
parent cfe32670e9
commit 2a2b873656
1 changed files with 3 additions and 5 deletions

View File

@ -37,23 +37,21 @@ import (
var outputPath = ""
func init() {
func main() {
flag.StringVar(&outputPath, "out", outputPath, "file to write")
flag.Parse()
flag.Lookup("logtostderr").Value.Set("true")
}
func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "must specify output file with --out\n")
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
func run() error {
if outputPath == "" {
return fmt.Errorf("must specify output file with --out\n")
return fmt.Errorf("must specify output file with --out")
}
glog.Info("Beginning AWS Machine Refresh")