GoLocalShare
GoLocalShare is a lightweight file sharing server built with Go that enables fast, private, and secure file transfers either over your local network or via a temporary cloud link. It was designed to be frictionless β no signups, no complex setup, and no reliance on slow internet uploads for local sharing. With one command, it launches a secure server, generates a session token, and makes your files accessible through a simple browser interface.
π― Motivation
Most file sharing tools today are tied to cloud services, which often come with:
- Slower transfer speeds due to internet bandwidth limits.
- Privacy concerns from storing files on third-party servers.
- Extra steps like sign-ups, installations, or syncing.
I wanted something that could:
- Use LAN speeds for instant sharing when possible.
- Maintain privacy by keeping files on my machine unless I choose otherwise.
- Offer remote sharing as an optional, temporary feature.
The result was GoLocalShare β a hybrid solution that blends the speed of peer-to-peer local transfers with the convenience of short-lived cloud sharing.
π οΈ How It Works
When GoLocalShare starts, it:
- Launches a small HTTP server in the background.
- Generates a unique, random token for the session.
- Prints a shareable URL to the terminal.
- Validates every request against the session token before serving files.
- Automatically shuts down access once the session expires.
For remote sharing, it integrates with Cloudinary. Files are uploaded at the start of the session and automatically deleted once the time limit ends.
β¨ Core Principles
- Simplicity β Start sharing in seconds with one command.
- Security β All access is token-based and time-limited.
- Flexibility β Works both offline (LAN) and online (cloud).
π Technical Approach
GoLocalShare uses Goβs net/http
package for its backend, with Gorilla Mux handling routing. Middleware enforces token authentication, rate limits, and secure headers like Content-Security-Policy and X-Content-Type-Options to prevent XSS and MIME sniffing.
In cloud mode, it uses the Cloudinary API to store files temporarily, returning a signed URL to recipients. File cleanup is automated at session end.
The frontend is intentionally minimal β a plain HTML and JavaScript interface for both the owner panel (to see tokens and reset sessions) and the user view (to browse and download files). This ensures full cross-platform support without extra dependencies.
π Example Use Case
If I need to send a large 500MB video to a teammate on the same network, I can run:
./goLocalShare --duration 2h /path/to/video.mp4
Within seconds, I have a local URL and token to share. The recipient enters the token in their browser and downloads the file at LAN speed β avoiding slow cloud uploads entirely.
If the teammate is remote, I can instead run:
./goLocalShare --cloud --duration 1h /path/to/video.mp4
This creates a secure cloud link that automatically expires and deletes the file after an hour.
π Security Highlights
- Token-based access β Unique per session and unpredictable.
- Rate limiting β 100 requests/minute per IP.
- Brute-force protection β 2-second delay after failed attempts.
- Path & symlink protection β No file access outside shared directories.
- Secure headers β CSP, no-sniff, and XSS protections by default.
π Live Demo & Code
- Live Demo: golocalshare.pages.dev
- Source Code: github.com/pavandhadge/goLocalShare
βGoLocalShare taught me how to design for speed, security, and simplicity in a networked application β all while keeping the user experience effortless.β