title | description |
---|---|
Live Server for Golang |
A simple live-reloading static file server built in Golang. |
A lightweight, fast, and feature-rich live server built with Go. It serves static files, watches for changes, and reloads the browser automatically.
- π Serve static files from any directory
- π Live reload when files change
- β‘ Customizable port (
-port=3000
) - π Directory listing (if
index.html
is missing) - π Auto-open browser
- π Ignore specific directories (
-ignore=node_modules
) - π― Filter file types to watch (
-watch=.html,.css,.js
) - π Watch multiple directories
- π SSL support (to be added later)
git clone https://github.com/your-repo/go-live-server.git
cd go-live-server
go build -o go-file-serve
./go-file-serve [path_to_you_directory]
./go-file-serve public
Flag | Default | Description |
---|---|---|
-port |
8080 |
Set the port for the server |
-ignore |
node_modules |
Ignore directories (comma-separated) |
-watch |
.html,.css,.js |
File types to watch for live reload |
-open |
true |
Automatically open browser |
Serve the dist
folder on port 3000
, ignoring logs
:
./go-file-serve -port=3000 -ignore=logs dist
Include this script inside your HTML files for live reloading:
<script>
const ws = new WebSocket(`ws://${location.host}/ws`);
ws.onmessage = () => location.reload();
</script>
For testing, run:
go run main.go public
MIT License.