Converting FileDitch to Go

Converting FileDitch from Node.js to Go

Hey everyone! Remember FileDitch, our temporary file sharing service? I recently decided to rewrite it in Go, and I wanted to share my experience with the conversion process, the challenges faced, and the improvements gained.

Why Go?

While the Node.js version worked well, I had a few motivations for switching to Go:

  1. Better Resource Management: Go's built-in concurrency and lower memory footprint make it ideal for handling multiple file uploads.
  2. Simpler Deployment: A single binary with no runtime dependencies (except SQLite) makes deployment much easier.
  3. Type Safety: Static typing helps catch errors at compile time rather than runtime.
  4. Standard Library: Go's standard library is comprehensive, reducing external dependencies.

Architecture Overview

Here's how we structured the Go version:

Flow structure

Request Flow

The upload process in the Go version:

Request flow

Database Structure

Our SQLite schema visualization:

Database schema

Cleanup Process

The file cleanup system runs as a background goroutine:

Cleanup process

Performance Improvements

Here's how the Go version compares to Node.js:

Performance comparison

Deployment Architecture

Our deployment setup with Go:

Deployment architecture

Development Workflow

The development process became more streamlined:

Development workflow

What's Next?

Here are the planned improvements for the Go version:

Planned improvements

Concluding

The complete code is available in the same repository. The go version is now the default branch.

Feel free to try out the new version and let me know your thoughts!