Skip to content

pablodeas/go_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Go Server

A minimalist static file server for Go with automatic browser reloading via WebSockets.

Features

  • Live Reload: Automatically refreshes the browser when files are saved.
  • Script Injection: Injects the WebSocket client into HTML files on the fly.
  • Recursive Watcher: Monitors the current directory and all subdirectories.
  • Debounced Events: Prevents multiple rapid refreshes.

Quick Start

  1. Install dependencies:
go mod tidy
  1. Run the server:
go run main.go
  1. Open your browser: Navigate to http://localhost:9797

To build

go build -o goserver main.go

How it works

  1. The server watches for Write or Create events using fsnotify.
  2. It serves static files and injects a small <script> before the </body> tag in HTML files.
  3. When a file change is detected, a signal is sent via WebSockets to all connected clients to trigger window.location.reload().

About

A server that checks for changes in files and update in real time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages