htmgo - build simple and scalable systems with go + htmx
The commit introduces an atomic GetOrCompute method to the cache interface and refactors all cache implementations to use it. This prevents race conditions and duplicate computations when multiple goroutines request the same uncached key simultaneously. The changes eliminate a time-of-check to time-of-use race condition in the original caching implementation, where separate Get/Set operations could lead to duplicate renders under high concurrency. With GetOrCompute, the entire check-compute-store operation happens atomically while holding the lock, ensuring only one goroutine computes a value for any given key. The API change is backwards compatible as the framework handles the GetOrCompute logic internally. Existing applications will automatically benefit from the |
||
|---|---|---|
| .github | ||
| cli/htmgo | ||
| examples | ||
| extensions/websocket | ||
| framework | ||
| framework-ui | ||
| htmgo-site | ||
| templates/starter | ||
| tools | ||
| .gitignore | ||
| CODE_OF_CONDUCT.md | ||
| LICENSE | ||
| README.md | ||
| tailwind-lsp-config.json | ||
htmgo
build simple and scalable systems with go + htmx
looking for a python version? check out: https://fastht.ml
introduction:
htmgo is a lightweight pure go way to build interactive websites / web applications using go & htmx.
By combining the speed & simplicity of go + hypermedia attributes (htmx) to add interactivity to websites, all conveniently wrapped in pure go, you can build simple, fast, interactive websites without touching javascript. All compiled to a single deployable binary.
func IndexPage(ctx *h.RequestContext) *h.Page {
now := time.Now()
return h.NewPage(
h.Div(
h.Class("flex gap-2"),
h.TextF("the current time is %s", now.String())
)
)
}
core features:
- deployable single binary
- live reload (rebuilds css, go, ent schema, and routes upon change)
- automatic page and partial registration based on file path
- built in tailwindcss support, no need to configure anything by default
- custom htmx extensions to reduce boilerplate with common tasks
get started:
View documentation on htmgo.dev.