mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 14:50:46 +00:00
22 lines
298 B
Go
22 lines
298 B
Go
package util
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
)
|
|
|
|
func ReadLines(r io.Reader) ([]string, error) {
|
|
lines := []string{}
|
|
|
|
scanner := bufio.NewScanner(r)
|
|
for scanner.Scan() {
|
|
lines = append(lines, scanner.Text())
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
return []string{}, err
|
|
}
|
|
|
|
return lines, nil
|
|
}
|