Golang:自动刷新HTTP页面

I have a HTTP page getting executed using Go programming language. The function in GO looks like this:

func main(){
    ...
    http.HandleFunc("/Page", func(w http.ResponseWriter, r *http.Request) {
        t:=template.New("New template")
        child_template := t.New("New child template")
        _, _ = child_template.Parse(output)  // output is from the omitted code
        t, err = t.ParseFiles("HTML_template.html")
        _ = t.ExecuteTemplate(w, "HTML_template.html", output)
    }
}

How do I make /Page refreshes by itself? I have tried the following, but it doesn't work.

func main(){
    ...
    http.HandleFunc("/Page", func(w http.ResponseWriter, r *http.Request) {
        for{
            t:=template.New("New template")
            child_template := t.New("New child template")
            _, _ = child_template.Parse(output)  // output is from the omitted code
            t, err = t.ParseFiles("HTML_template.html")
            _ = t.ExecuteTemplate(w, "HTML_template.html", output)

            time.Sleep(time.Millisecond*100)
        }
    }
}

I am trying to make a dynamic graph that plots the number of incoming data per second. If I keep making the browser refreshes, the axis will get reloaded too and it looks ugly. The HTML_template.html looks like this

<script type = "text/javascript">
    function plot(){
        ...
        var data = [{{template "New child template"}}];
        ...
    }
    setInterval(func(){plot()},500);
</script>

You're going at this the wrong way, you should use Websockets Gorilla's or go.net's or at the very least use ajax, but reloading the whole page is very inefficient.

This can be done without Go, JavaScript, AJAX, SSE or Websockets by simply adding the refresh meta tag. Adding

<meta http-equiv="refresh" content="3" />

into your page's <head> will cause it to refresh every 3 seconds.

Your really really really need to use websockets to do this but there is a quick and dirty method.

Add a little jquery to the page:

if (window.location.href.indexOf('reload')==-1) {
     window.location.replace(window.location.href+'?reload');
}

But you really need to use websockets.