26 lines
394 B
Go
26 lines
394 B
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func GetCardNamesFromFile(filename string) ([]string, error) {
|
||
|
var cardNames []string
|
||
|
|
||
|
file, err := os.Open(filename)
|
||
|
defer file.Close()
|
||
|
if err != nil {
|
||
|
return cardNames, err
|
||
|
}
|
||
|
|
||
|
scanner := bufio.NewScanner(file)
|
||
|
scanner.Split(bufio.ScanLines)
|
||
|
|
||
|
for scanner.Scan() {
|
||
|
cardNames = append(cardNames, scanner.Text())
|
||
|
}
|
||
|
|
||
|
return cardNames, nil
|
||
|
}
|