Im trying to build a small website, I use the html/template to create dynamic pages. One thing on the pages is a list of URL's inside those urls sometimes I need character encoding. for special characters like ô (%C3%B4).
When i try to parse the variables into a page using html/template i get the following as a result: %!c(MISSING)3%!b(MISSING)4. I have no clue what is wrong here
type Search_list struct { Search_name string Search_url string Search_price float64 } func generateSearchPage(language int, q string) (string, error) { /* ommited, fetshing data from elasticsrearch*/ sl := []Search_list{} var urle *url.URL //looping through ES results and putting them in a custom List for _, res := range data.Hits.Hits { // //Encode Url var err error urle, err = url.Parse(res.Source.URL) if err != nil { continue // TODO: add log } //I've tried already the following: fmt.Println(res.Source.URL) //ô fmt.Println(url.QueryUnescape(res.Source.URL)) //ô fmt.Println(urle.String()) //%C3%B4 u, _ := url.QueryUnescape(res.Source.URL) sl = append(sl, Search_list{res.Source.Name, u, res.Source.Price}) } var buffer bytes.Buffer t := template.New("Index template") t, err = t.Parse(page_layout[language][PageTypeSearch]) if err != nil { panic(err) } err = t.Execute(&buffer, Search_data{ Title: translations[language]["homepage"], Page_title: WebSiteName, Listed_items: sl, }) if err != nil { panic(err) } return buffer.String(), nil // %!c(MISSING)3%!b(MISSING)4 }