Go
This guide will show how to use hop in a Go project.
We start by writing a simple hop file.
hop
<Index {name: String}>
Hello {name}!
</Index>Now we compile the hop code to native Go code.
bash
hop compileNow the generated Go code is available in the folder ./frontend so we can import it in the backend.
Now, let's define a simple backend using the standard library.
go
package main
import (
"net/http"
"frontend"
)
func main() {
router := http.NewServeMux()
router.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
frontend.PageIndex(w, frontend.PageIndexParams {
name: "Tobi"
})
})
http.ListenAndServe(":8080", router)
}Now hop is integrated into the backend, and we can run hop dev to start the server and get hot-reloading.