Skip to content

Live Server for Golang – A lightweight static file server with live reload, WebSocket support, and auto-browser refresh. Easily serve files with custom ports and watch for changes. πŸš€

Notifications You must be signed in to change notification settings

asyncnavi/go-file-serve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

title description
Live Server for Golang
A simple live-reloading static file server built in Golang.

πŸš€ Live Server for Golang

A lightweight, fast, and feature-rich live server built with Go. It serves static files, watches for changes, and reloads the browser automatically.

✨ Features

  • πŸ“‚ 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)

πŸ“¦ Installation

1. Clone the repository

git clone https://github.com/your-repo/go-live-server.git
cd go-live-server

2. Build the binary

go build -o go-file-serve

2. Run the server

./go-file-serve [path_to_you_directory]

πŸ“¦ CLI Usage

./go-file-serve public

Available Flags

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

Example

Serve the dist folder on port 3000, ignoring logs:

./go-file-serve  -port=3000 -ignore=logs dist

🌍 Live Reload Setup

Include this script inside your HTML files for live reloading:

<script>
    const ws = new WebSocket(`ws://${location.host}/ws`);
    ws.onmessage = () => location.reload();
</script>

πŸ› οΈ Development

For testing, run:

go run main.go public

πŸ“œ License

MIT License.

About

Live Server for Golang – A lightweight static file server with live reload, WebSocket support, and auto-browser refresh. Easily serve files with custom ports and watch for changes. πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages