Goact is a better way of pushing HTML to the client.
Linux
./goact
Windows
.\goact.exe
Linux
./goact -test
Windows
.\goact.exe -test
This will detect file changes, recompile and run the binary.
Here is a test program:
package main
import (
"net/http"
"strconv"
)
func main() {
http.HandleFunc("/", server)
http.ListenAndServe(":80", nil)
}
var i int = 0
func server(w http.ResponseWriter, r *http.Request) {
i++
echo(
html
head
body
div#content
h1 = "It works!"
footer
p{"style":"color:red"} = "Visitors: "+strconv.Itoa(i)
)
}
Instead of using
w.Write(`<html>...</html>`)
we are usingecho()
.
Each line is an element. The hiearchy is done by indenting lines, childs of an element will be indented with one more tabulation. The indentation only works with tabulations. You can add one information per element and a content.
element#id
Will set an id to the element.
element.class
Will set a class to the element.
element{"class": "class1 class2", "alt": "I'm an element."}
Where not put in "
, key and values can be go variables.
element = "some text"+someVariable
Will set the content of an element to the quoted text or the value of the passed code (variable/function).
Added support for use of functions
span.number = strconv.Itoa(i)
Support for multiple attribute per element
div.col.row#test