Move flag parse to main func from init()

This commit is contained in:
whypro 2019-09-16 14:32:46 +08:00
parent 41b3e60f0e
commit 69f48d87a4
2 changed files with 2 additions and 5 deletions

View File

@ -69,7 +69,7 @@ func handleFlags() {
flag.Parse() flag.Parse()
} }
func init() { func TestMain(m *testing.M) {
// Register test flags, then parse flags. // Register test flags, then parse flags.
handleFlags() handleFlags()
@ -105,9 +105,6 @@ func init() {
AssetNames: generated.AssetNames, AssetNames: generated.AssetNames,
}) })
}
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
os.Exit(m.Run()) os.Exit(m.Run())
} }

View File

@ -45,11 +45,11 @@ func init() {
// Set this to false to undo util/logs.go settings it to true. Prevents cadvisor log spam. // Set this to false to undo util/logs.go settings it to true. Prevents cadvisor log spam.
// Remove this once util/logs.go stops setting the flag to true. // Remove this once util/logs.go stops setting the flag to true.
flag.Set("logtostderr", "false") flag.Set("logtostderr", "false")
flag.Parse()
} }
// TODO: Should we write an e2e test for this? // TODO: Should we write an e2e test for this?
func main() { func main() {
flag.Parse()
o := strings.Split(*checkFlag, ",") o := strings.Split(*checkFlag, ",")
errs := check(o...) errs := check(o...)
if len(errs) > 0 { if len(errs) > 0 {