ReadFileIntoLines reads contents from a file and returns lines.
(filename string)
| 22 | |
| 23 | // ReadFileIntoLines reads contents from a file and returns lines. |
| 24 | func ReadFileIntoLines(filename string) ([]string, error) { |
| 25 | file, err := os.Open(filename) |
| 26 | if err != nil { |
| 27 | return nil, err |
| 28 | } |
| 29 | defer func() { |
| 30 | if err := file.Close(); err != nil { |
| 31 | klog.Errorf("Failed to close file %s: %v", filename, err) |
| 32 | } |
| 33 | }() |
| 34 | |
| 35 | var result []string |
| 36 | s := bufio.NewScanner(file) |
| 37 | for s.Scan() { |
| 38 | result = append(result, s.Text()) |
| 39 | } |
| 40 | if s.Err() != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | return result, nil |
| 44 | } |
| 45 | |
| 46 | func ContainsModule(key string, values []Module) bool { |
| 47 | for _, val := range values { |
no test coverage detected