go.ngs.io/servedir

Simple HTTP server that hosts local directory statically.

go get go.ngs.io/servedir
Version:
v1.0.2
License:
MIT
Author:
ngs
Repository:
https://github.com/ngs/servedir
Documentation:
https://pkg.go.dev/go.ngs.io/servedir
Last Updated:
2025-08-12T12:17:30Z

servedir

CI Go Report Card Go Reference

A simple HTTP file server with Apache-style logging for serving static files from any directory.

Features

  • 🚀 Simple and lightweight HTTP file server
  • 📝 Apache Combined Log Format output
  • 🔧 Configurable port
  • 🖥️ Auto-open browser (cross-platform)
  • 📁 Serve any directory

Installation

Using Go Install

go install go.ngs.io/servedir@latest

Download Binary

Download the latest binary from the releases page.

Build from Source

git clone https://github.com/ngs/servedir.git
cd servedir
make build

Usage

Basic Usage

Serve current directory on any available port:

servedir

Serve Specific Directory

servedir /path/to/directory

Custom Port

servedir -port 8080 .

Auto-open Browser

servedir -open -port 8123 .

Command Line Options

-port int    HTTP Port to Listen (default 0, any available port)
-open        Open browser on started

Development

Prerequisites

  • Go 1.21 or later
  • Make (optional)

Building

make build

Testing

make test

Running Locally

make run

Available Make Commands

make help       # Show all available commands
make build      # Build the binary
make test       # Run tests
make coverage   # Generate coverage report
make lint       # Run golangci-lint
make fmt        # Format code
make clean      # Remove build artifacts

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Author

Atsushi Nagase

License

Copyright © 2018 Atsushi Nagase. All rights reserved.

This project is licensed under the MIT License - see the LICENSE file for details.