Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 1.06 KB

README.md

File metadata and controls

34 lines (24 loc) · 1.06 KB

Go AutoF5

AutoF5 is a simple no dependency middleware to automatically reload your browser when go application restarts. It is useful when you are developing a web application and want to see the changes immediately after you rebuild and restart.

It injects a script tag into the html response to reload the browser every time the go application restarts. It does not require any browser extension or any other client-side code.

AutoF5 does not watch the file system or rebuild the go application. You must use other tools similar to Air, wgo to rebuild and restart the go application when a file changes.

Installation

go get -u github.com/mua/go-autof5

Usage

package main

import (
    "fmt"
    "net/http"
    "time"

    "github.com/mua/go-autof5"
)

func main() {    
   http.HandleFunc("/", autof5.AutoF5(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "<html><body><h1>AutoF5</h1></body></html>")
    }))
    http.ListenAndServe(":8080", nil)
}