I bundle React app with Webpack after I call it in HTML file. However, it error when I using Golang and html/template to view HTML file.
My HTML file: index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Note App</title>
</head>
<body>
<div id="root"></div>
<script src="public/bundle.js"></script>
</body>
</html>
My Golang file: index.go
package main
import (
"net/http"
"html/template"
"path/filepath"
)
func handle(w http.ResponseWriter, r *http.Request) {
fp := filepath.Join("views", "index.html")
t := template.Must(template.ParseFiles(fp))
t.Execute(w, nil)
}
func main() {
http.HandleFunc("/", handle)
http.ListenAndServe(":8080", nil)
}