Mapping news data – Go Lang Practical Programming Tutorial p.15

Welcome to part 15 of the Go programming tutorial series, where we’ll be incorporating a map into our sitemap that we’ve pulled.

One issue we’re going to come across immediately is when we find ourselves wanting to store 2 or more values in the map’s value, because we can only specify one type. Have we any idea for how to create a type that contains multiple values? Sure we do! Structs!

Text tutorials and sample code:


Ritesh Kumar Maurya says:

Hey Sentdex, you should watch my video on Google Cloud Speech Recognition API, which you forgot to put in your Google Cloud Playlist. The link is:

sate plate says:

I am getting all the titles from the first url only and for rest of the urls ,the same titles are repeated
Seems like xml.Unmarshal(bytes &n) in loop is causing that issue. if I create ” var n News” in each loop then I see correct titles from all the urls.

Robert Solomon says:

The News structure has several slices as its fields. How do we know that these slices are all the same length? That is, can there be more than one keyword for the same location?

Ashok Kumar says:

Nice tutorial.

Seppänen Juho says:

All of the sections are not populated, how to handle that?

Boyan Bonev says:

Amazing tutorials. Really glad that I found them. A slight suggestion – I found using only one struct (News) for both handling the news and the hash map much easier to understand.

Artem Kovera says:

Hello, guys! I just published an e-book about clustering algorithms (hierarchical clustering, k-means, DBSCAN, Kohonen neural networks) in Python, called “Machine Learning with Clustering: A Visual Guide for Beginners with Examples in Python 3”. It’s available for FREE on Amazon until 3rd November.

Nico Wolters says:

It’s irritating me that the xml package isn’t returning an empty string, when it can’t find the tag. This way it’s hard to iterate through the structure when the slices are of different sizes. Has anyone found an easy fix for this?

Abeltensor says:

Again using a hashmap seems like a weird choice in this situation. You’ve already got things in a struct, you could easily just use that to iterate and print out the information and it would be much more intuitive and less costly then using a map like this.

Zhengqun Koo says:

If anyone is bothered by the formatting, use this!

MeMReS says:

Noticed something interesting with maps the order changes when you loop through them so you can’t count on the order you created them as just hitting the Run button a few times suggests the order is random

Miles Munro says:

Probably you should take a look at watching it from another angle here Anyway, I really like the concept of this video and I feel that this is a very unique and rare information that you have managed to compile.

Muhammad Hussein Fattahizadeh says:

iv got an error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x60121a]

goroutine 1 [running]:
/home/sweb/gotut/tut.go:29 +0x8a
exit status 2
Line 29:
bytes, _ := ioutil.ReadAll(resp.Body)

ayush sharma says:

what about angular js for web application ?

Lorenzo says:

It’s about time! : )

Sifiso Nkabinde says:

Hello Sentdex, Great video

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!