That's a lot of code.
curl -s "https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&format=json&redirects&explaintext&prop=text§ion=0&page=golang" | jq .parse.text.\"*\" > temp.html; links temp.html
(Scroll that). Not quite the same, but...Nice, would be interesting to have a shorter version. Maybe until the first dot?
Isn't this what DBPedia's SPARQL endpoint was built for?
Construct a query with predicate as http://dbpedia.org/ontology/abstract and you have your summary.