diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index b2e5217..2441370 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -174,7 +174,7 @@ func Execute() { } } -func init() { {{if .viper}} +func init() { {{- if .viper}} cobra.OnInitialize(initConfig) {{end}} // Here you will define your flags and configuration settings. diff --git a/cobra/cmd/testdata/root.go.golden b/cobra/cmd/testdata/root.go.golden index a76a767..d74f4cd 100644 --- a/cobra/cmd/testdata/root.go.golden +++ b/cobra/cmd/testdata/root.go.golden @@ -49,7 +49,7 @@ func Execute() { } } -func init() { +func init() { cobra.OnInitialize(initConfig) // Here you will define your flags and configuration settings.