I'm using a template in a Go web application which should show an image depending on which country the visitor is from.
For the images I use the FileServer
http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("images"))))
In the template the variable country is passed so the application knows which flag to show.
<img id='flag' src='images/{{ .Country}}.png'>
However, for some reason the string I pass adds %0a which causes the src of the img to be wrong.
<img id='flag' src='images/BE%0A.png'>
The expected output should be
<img id='flag' src='images/BE.png'>
The following code is used to grab the country string
resp3, err := http.Get("https://ipinfo.io/country")
if err != nil {
fmt.Println(err)
}
bytes3, _ := ioutil.ReadAll(resp3.Body)
country := string(bytes3)
Could anyone help me resolve this issue?