Learning Golang. Day 5
Here we are on day 5 – the end of the first week. Today, I solved the Slices exercise!
Here I am at day 4. Today, I learned about the range function and started the slices exercise…but got stuck.
:idseparator: - :idprefix: :experimental: :source-highlighter: rouge :rouge-style: pastie :imagesdir: /images :source-linenums-option: on :tip-caption: 💡
Today’s session felt like a pretty short one. It wasn’t. It was the same length as the previous 3 sessions. However, it was almost wholly spent doing https://go.dev/tour/moretypes/18[the slices exercise].
I’m trying not to be hard on myself for finishing the exercise and taking a while to appreciate the exercise’s requirements. I misunderstood them the first few times, so kept re-reading the instructions until they sunk in. It’s odd, but at times like this, I crazily expect myself to understand things straightaway, and am not always patient while learning a new domain of knowledge.
After I felt comfortable that I knew what was being asked, using https://www.jetbrains.com/go/[Goland] (my, current, favourite Go IDE) I started playing around with some ideas for a solution.
I skipped backward and forward throughout the tour to find the various functions and language elements that had been covered up to this point, and tried to stick just to those.
I wrote up a small solution for the Pic
function and checked that it worked.
It did, but when it came time to run it, the code failed.
It took me quite a while to appreciate what was going on, that being that pic.Show
takes a function, not the result of a function, which is what I was passing to it.
By the time I realised this, https://gnomepomodoro.org/[my Pomodoro timer] was down to 35 seconds.
I kept looking and looking at the code, hoping to have a lightbulb moment so that I could finish up the implementation before the time was up. Alas, it didn’t happen.
As often happens with me, when I get stuck on something, I didn’t let it go and pushed on for a minute or two longer. I know that I said I’d stick to the 30-minute time limit. But I didn’t want to, today. I felt that I was, potentially, on the cusp of getting the concept at hand, so felt it was worth working just a bit longer.
I looked at the source of pic.Show
and finally appreciated why the code wasn’t working; that Pic
function is called inside pic.Show
, where it is passed two integers.
Given that, hopefully in the next time session, I’ll be able to finish up my implementation of Pic and move on with the Go tour.
See you link:/learning-golang/day-5/[next time!]
Here we are on day 5 – the end of the first week. Today, I solved the Slices exercise!
Today, on day 14, I created a custom method to remove code duplication creeping into the weather station codebase. Come read the fun story behind getting that done.
Here we are on day 13. Today, I continued learning Golang by working on the Golang version of my PHP/Python weather station, adding a function to render static pages. Let me share my learnings with you.
Here we are on day 12. I didn’t solve anything. I’m feeling that these exercises are becoming arbitrary and pointless.
Please consider buying me a coffee. It really helps me to keep producing new tutorials.
Join the discussion
comments powered by Disqus