func initConfig() {
	if cfgFile != "" {
		viper.SetConfigFile(cfgFile)
	} else {
		home, err := os.UserHomeDir()
		cobra.CheckErr(err)
		viper.AddConfigPath(home)
		viper.SetConfigType("yaml")
		viper.SetConfigName(".zping")
	}
	viper.AutomaticEnv()  
	if err := viper.ReadInConfig(); err == nil {
		fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
	}
}
initConfig reads in config file and ENV variables if set.
package cmd
import (
	"fmt"
	"github.com/spf13/cobra"
	"os"
	"github.com/spf13/viper"
)
var cfgFile string
var rootCmd = &cobra.Command{
	Use:   "zping",
	Short: "Latency Diagnostic tool for ziti",
	Long: `zping replaces the function of icmp ping tool in a ziti network.
It provides an end to end latency measurment between any two ziti identities in
a ziti network and like icmp ping will provide the following metrics upon completion
of the ping session: min, max and mean latency and standard deviation as well as % loss.
zping uses the addressable terminator function of ziti to direct ping requests to
specific ziti identities.`,
}
func Execute() {
	cobra.CheckErr(rootCmd.Execute())
}
func init() {
	cobra.OnInitialize(initConfig)
}