HTML Link Parser
Gophercises Exercise Details:
In this exercise your goal is create a package that makes it easy to parse an HTML file and extract all of the links (<a href="">...</a>
tags). For each extracted link you should return a data structure that includes the href
.
Links will be nested in different HTML elements, and it is very possible that you will have to deal with HTML similar to code below.
<a href="/dog">
<span>Something in a span</span>
Text not in a span
<b>Bold text!</b>
</a>
In situations like these we want to get output that looks roughly like:
Link{
Href: "/dog",
}
Once you have a working program, try to write some tests for it to practice using the testing package in go.
Technical Notes