package file import ( "bufio" "os" "strings" ) // Read a file func Read(path string) ([]string, error) { // Store lines var lines []string // Open file file, err := os.Open(path) if err != nil { return lines, err } defer file.Close() // Create scanner scanner := bufio.NewScanner(file) // Go through scanner for scanner.Scan() { // Store line line := scanner.Text() // Ignore empty & commented lines if line != "" && !strings.HasPrefix(line, "#") { lines = append(lines, strings.ToLower(line)) } } return lines, nil }