Will this command be necessary after we we roll this out, or is it a one-time thing?
No need for this or any other res.Body.Close()
if you defer above like is recommended.
I don't think it really matters, but you could simply use FindAllSubmatch
on partialHtml
instead of converting to a string and using FindAllStringSubmatch
. Everything in the regexp
package has byte[]
and string
equivalents.
Also, naming nitpick, I think we could name this metaTags
or something because I got confused and had to look back up to see what matches
was actually matching.
Is it even possible for this if statement to be false? For each matched meta tag, you should always have a slice with two elements.
What is prop
used for? I'm confused. We don't seem to return it or use it in any way?
It's recommended that http.Client
is reused where possible instead of created every time, because the client's Transport
has an internal cache that is good to keep around. (See the docs.) So I think this should be moved to a package-level variable.
You should defer res.Body.Close()
right after this so you don't have to worry about it elsewhere. (This is what they do in the http
package docs.)
Also, naming nitpick, I think we could name this metaTags
or something because I got confused and had to look back up to see what matches
was actually matching.