Working file parser implemented
Signed-off-by: Eoghan Conlon <git@eoghanconlon.ie>
This commit is contained in:
parent
ec954d1577
commit
6bacc5c2b6
3 changed files with 29 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
.idea/
|
.idea/
|
||||||
|
input/
|
23
src/Helpers.go
Normal file
23
src/Helpers.go
Normal 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
|
||||||
|
}
|
|
@ -3,5 +3,8 @@ package main
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Hello World")
|
input := FileParse("input/test.txt")
|
||||||
|
for _, s := range input {
|
||||||
|
fmt.Println(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue