Repos / s4g / 5e0c7e4dc1
commit 5e0c7e4dc174f88891d6770028b47d940787451d
Author: Nhân <hi@imnhan.com>
Date: Sun Jul 9 13:09:34 2023 +0700
init state.clients right next to declaration
diff --git a/livereload/livereload.go b/livereload/livereload.go
index e7de673..dfd7926 100644
--- a/livereload/livereload.go
+++ b/livereload/livereload.go
@@ -20,18 +20,18 @@
var pleaseReload = []byte("1")
var dontReload = []byte("0")
-var state struct {
+var state = struct {
// Maps each client ID to whether they should reload on next ajax request.
//
// Client IDs are generated on client side so that an open tab's
// livereload feature keeps working even when the server is restarted.
clients map[string]bool
mut sync.RWMutex
+}{
+ clients: make(map[string]bool),
}
func init() {
- state.clients = make(map[string]bool)
-
lrScript = bytes.ReplaceAll(
lrScript, []byte("{{LR_ENDPOINT}}"), []byte(endpoint),
)