From 67565fd9cb063d4e01bec3d13afada1193823a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 5 Dec 2021 00:39:40 +0100 Subject: [PATCH] Move readFile to own package --- day01/main.go | 6 ++++-- day01/utils.go => utils/readfile.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename day01/utils.go => utils/readfile.go (84%) diff --git a/day01/main.go b/day01/main.go index ad5fd1a..67bc52e 100644 --- a/day01/main.go +++ b/day01/main.go @@ -3,6 +3,8 @@ package day01 import ( "fmt" "log" + + "git.xenrox.net/~xenrox/aoc2021/utils" ) func Run() { @@ -22,7 +24,7 @@ func Run() { } func calc1(path string) (int, error) { - lines, err := readFile(path) + lines, err := utils.ReadFileToInt(path) if err != nil { return 0, err } @@ -38,7 +40,7 @@ func calc1(path string) (int, error) { } func calc2(path string) (int, error) { - lines, err := readFile(path) + lines, err := utils.ReadFileToInt(path) if err != nil { return 0, err } diff --git a/day01/utils.go b/utils/readfile.go similarity index 84% rename from day01/utils.go rename to utils/readfile.go index 448b257..3f85e0a 100644 --- a/day01/utils.go +++ b/utils/readfile.go @@ -1,4 +1,4 @@ -package day01 +package utils import ( "bufio" @@ -6,7 +6,7 @@ import ( "strconv" ) -func readFile(path string) ([]int, error) { +func ReadFileToInt(path string) ([]int, error) { var lines []int f, err := os.Open(path) -- 2.44.0