I'm quite new to Go and I feel like this code could be smaller and cleaner.
I would love any suggestions and/or hints about mistakes and conventional go things!
func getBookTitle(client *http.Client) {
rsp, err := client.Get(bookSite)
if err != nil {
panic(err)
}
html, _ := ioutil.ReadAll(rsp.Body)
//Get div with title
regTitle := regexp.MustCompile("(<div class=\"dotd-title\">)[\n+\\s]*(<h2>)[a-zA-Z–\\-\n\\s:]*(</h2>)[\n+\\sdd]*(</div>)")
//remove linebreaks regex
regFormatTitle := regexp.MustCompile("[\r\n]*")
//apply regex
title := regFormatTitle.ReplaceAllString(string(regTitle.Find(html)),"")
//Remove remove html tags and remove whitespaces
title = strings.TrimSpace(title[strings.Index(title,"<h2>")+len("<h2>"):strings.Index(title,"</h2>")])
fmt.Printf("Book title:%s\n",title)
rsp.Body.Close()
}