diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index b2e52176..24413701 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 a76a7672..d74f4cd4 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.