// readConfig reads configuration file.
readConfig reads configuration file.
// readConfig reads configuration file .
func readConfig(file string) (*Config, error) {
	if file == "" {
		file = filepath.Join(os.Getenv("HOME"), ConfigName)
	}
	_, err := os.Stat(file)
	if err != nil {
		return nil, err
	}
	jsondata, err := ioutil.ReadFile(file)
	if err != nil {
		return nil, err
	}
	cfg := &Config{}
	err = json.Unmarshal(jsondata, &cfg)
	if err != nil {
		return nil, err
	}
	if cfg.TimeoutValue != 0 {
		cfg.timeout = time.Duration(cfg.TimeoutValue) * time.Second
	} else {
		cfg.timeout = defaultTimeout
	}
	return cfg, nil
}
func readConfig ( file string ) ( * Config , error ) { if file == " " { file = filepath . Join ( os . Getenv ( " " ) , ConfigName ) } _ , err := os . Stat ( file ) if err != nil { return nil , err } jsondata , err := ioutil . ReadFile ( file ) if err != nil { return nil , err } cfg := & Config { } err = json . Unmarshal ( jsondata , & cfg ) if err != nil { return nil , err } if cfg . TimeoutValue != 0 { cfg . timeout = time . Duration ( cfg . TimeoutValue ) * time . Second } else { cfg . timeout = defaultTimeout } return cfg , nil }
readConfig reads configuration file.
readConfig reads configuration file .