// loadRedisFile opens the specified file and loads the configuration for which redis
// hosts to monitor. Returns the list of hosts addrs, passwords, and their aliases.
loadRedisFile opens the specified file and loads the configuration for which redis
hosts to monitor. Returns the list of hosts addrs, passwords, and their aliases.
// loadRedisFile opens the specified file and loads the configuration for which redis // hosts to monitor . Returns the list of hosts addrs passwords and their aliases .
func LoadRedisFile(fileName string) ([]string, []string, []string, error) {
	var addrs []string
	var passwords []string
	var aliases []string
	file, err := os.Open(fileName)
	if err != nil {
		return nil, nil, nil, err
	}
	r := csv.NewReader(file)
	r.FieldsPerRecord = -1
	records, err := r.ReadAll()
	if err != nil {
		return nil, nil, nil, err
	}
	file.Close()
	for _, record := range records {
		length := len(record)
		switch length {
		case 3:
			addrs = append(addrs, record[0])
			passwords = append(passwords, record[1])
			aliases = append(aliases, record[2])
		case 2:
			addrs = append(addrs, record[0])
			passwords = append(passwords, record[1])
			aliases = append(aliases, "")
		case 1:
			addrs = append(addrs, record[0])
			passwords = append(passwords, "")
			aliases = append(aliases, "")
		}
	}
	return addrs, passwords, aliases, nil
}
func LoadRedisFile ( fileName string ) ( [ ] string , [ ] string , [ ] string , error ) { var addrs [ ] string var passwords [ ] string var aliases [ ] string file , err := os . Open ( fileName ) if err != nil { return nil , nil , nil , err } r := csv . NewReader ( file ) r . FieldsPerRecord = - 1 records , err := r . ReadAll ( ) if err != nil { return nil , nil , nil , err } file . Close ( ) for _ , record := range records { length := len ( record ) switch length { case 3 : addrs = append ( addrs , record [ 0 ] ) passwords = append ( passwords , record [ 1 ] ) aliases = append ( aliases , record [ 2 ] ) case 2 : addrs = append ( addrs , record [ 0 ] ) passwords = append ( passwords , record [ 1 ] ) aliases = append ( aliases , " " ) case 1 : addrs = append ( addrs , record [ 0 ] ) passwords = append ( passwords , " " ) aliases = append ( aliases , " " ) } } return addrs , passwords , aliases , nil }
loadRedisFile opens the specified file and loads the configuration for which redis
hosts to monitor.
loadRedisFile opens the specified file and loads the configuration for which redis hosts to monitor .
// For each line, test if it contains an optional password and alias and provide them, // else give them empty strings