Working file parser implemented

Signed-off-by: Eoghan Conlon <git@eoghanconlon.ie>
This commit is contained in:
Eoghan Conlon 2024-08-23 12:16:04 +01:00
parent ec954d1577
commit 6bacc5c2b6
3 changed files with 29 additions and 2 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.idea/
input/

23
src/Helpers.go Normal file
View file

@ -0,0 +1,23 @@
package main
import (
"bufio"
"log"
"os"
)
func FileParse(path string) []string {
oFile, err := os.Open(path)
if err != nil {
log.Fatal(err)
}
defer oFile.Close()
rValue := make([]string, 0)
scanner := bufio.NewScanner(oFile)
for scanner.Scan() {
rValue = append(rValue, scanner.Text())
}
return rValue
}

View file

@ -3,5 +3,8 @@ package main
import "fmt"
func main() {
fmt.Println("Hello World")
input := FileParse("input/test.txt")
for _, s := range input {
fmt.Println(s)
}
}