code: func generateConfig(f string) error {
  	exists, err := pathExists(f)
  	if err != nil {
  		return err
  	}
  	if exists {
  		return errors.New("output config file already exists: " + f)
  	}
  	ext := filepath.Ext(f)
  
  	if len(ext) > 1 {
  		ext = ext[1:]
  	}
  
  	supportedExts := []string{"json", "toml", "yaml", "yml"}
  
  	if !stringInSlice(ext, supportedExts) {
  		return errors.New("output config file must have one of supported extensions: " + strings.Join(supportedExts, ", "))
  	}
  
  	var t *template.Template
  
  	switch ext {
  	case "json":
  		t, err = template.New("config").Parse(jsonConfigTemplate)
  	case "toml":
  		t, err = template.New("config").Parse(tomlConfigTemplate)
  	case "yaml", "yml":
  		t, err = template.New("config").Parse(yamlConfigTemplate)
  	}
  	if err != nil {
  		return err
  	}
  
  	var output bytes.Buffer
  	t.Execute(&output, struct {
  		Secret        string
  		AdminPassword string
  		AdminSecret   string
  		APIKey        string
  	}{
  		uuid.NewV4().String(),
  		uuid.NewV4().String(),
  		uuid.NewV4().String(),
  		uuid.NewV4().String(),
  	})
  
  	err = ioutil.WriteFile(f, output.Bytes(), 0644)
  	if err != nil {
  		return err
  	}
  
  	err = validateConfig(f)
  	if err != nil {
  		_ = os.Remove(f)
  		return err
  	}
  
  	return nil
  }
docs: // generateConfig generates configuration file at provided path.