Skip to content
/ go-autof5 Public

Reloads browser when go application restarts

Notifications You must be signed in to change notification settings

mua/go-autof5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

Reloads browser when go application restarts

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages