programming go

My blog of the epic Advent of Code 2019. Just to write down what I learnt by solving the problems, leaning a new language: [goland]

day 1

did a bit of good old bash scripting to get the day input through curl

input_file, err := os.Open("input")
if err != nil {
   log.Fatal(err)
}

scanning line by line for integers

filescanner := bufio.NewScanner(input_file)
 
for filescanner.Scan() {
   line := filescanner.Text()
   i, err := strconv.Atoi(line)
   if err != nil {
   	log.Fatal(err)
   }
}

outputting to file

fmt.FPrint(result)

did some testing with a couple files test and results

day 2