func initConfig() {
	if cfgFile != "" {  
		viper.SetConfigFile(cfgFile)
	}
	viper.SetConfigName(".ago")   
	viper.AddConfigPath("$HOME")  
	viper.AutomaticEnv()          
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config file:", viper.ConfigFileUsed())
	}
}
initConfig reads in config file and ENV variables if set.
package cmd
import (
	"fmt"
	"os"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)
var cfgFile string
var RootCmd = &cobra.Command{
	Use:   "ago",
	Short: "A tool to generate design definitions of goa from swagger definitions.",
	Long:  `A tool to generate design definitions of goa from swagger definitions.`,
}
func Execute() {
	if err := RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}
func init() {
	cobra.OnInitialize(initConfig)
	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.ago.yaml)")
	RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}