how can I show the data data I created in go on the index html page? It puts an "." to the tutorial I watched, but the same code doesn't work for me. Can you help me?
package main
import (
"html/template"
"net/http"
)
func main() {
http.HandleFunc("/", anaSayfa)
http.ListenAndServe(":8080", nil)
}
func anaSayfa(w http.ResponseWriter, r *http.Request) {
view, _ := template.ParseFiles("index.html")
data := "Go'dan gelen veri"
view.Execute(w, data)
}
At the bottom, I have the index.html page.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Page Title</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<script src='main.js'></script>
</head>
<body>
<p>Selam</p>
{{
.
}}
</body>
</html>