Follow

Interested in learning programming with Go?

I'm doing a quick crash course with some live coding over on Twitch in about 20 minutes!

Join me:

twitch.tv/mueslix

@fribbledom thank you very much for making these video, and for putting them up on peertube too!
I just followed you there so I'll watch them when i get around to it ;)
Great work.

@fribbledom
great stuff, kann ich aber erst später anschauen. wieder auf peertube?

@plumps

Yep, will have to cut it down and edit it a bit, though. Links will be posted here, of course!

@fribbledom Great, now I wanna play with Go, instead of doing other stuff that I should be doing instead.
Kidding aside, this really looks worth spending some more time on. Thank you!

@fnord

Glad to hear you liked that quick introduction!

I'll certainly do a few more videos in the next couple days, so stay tuned!

In the meantime, I can highly recommend checking out the Golang Tour and Playground:

tour.golang.org/
play.golang.org/

Should have mentioned these links in the stream, really 😆

@fribbledom i think one partially unanswered question remained about the decoding JSON & putting it into a struct:

when you decode the JSON and bind it to j, then call j.City without City having been in the JSON, would that call keyerror, or rather pass nil silently, so you get the default empty string in the struct?

@gekitsu

Sorry that I missed that one!

If there's no "City" key in the JSON itself, then it would _not_ return an error. It tries to fill the struct to the best of its abilities. j.City wouldn't get touched in such a case and simply remain an empty string.

Similarly: if there's a "City" in the JSON, but no "j.City" member, it would simply ignore that and move on with the next value.

@gekitsu

I think that's rather reasonable behavior. It doesn't break your API clients just because a new member has been added to the JSON server-side.

@fribbledom yeah, it’s definitely reasonable, especially when you think long-running tasks in a networked environment where you don’t have control over all the parts.

and the standardising to a type’s default should mitigate some of the extended bug-hunting that can come from an unexpected nil being passed through a process made for actual data.

it’ll just require some mental adjustment coming from python, but that’s to be expected. :)

@fribbledom
Thanks for the intro and thanks for the VOD so I can work through it at my own pace. I hope you keep doing these!

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!