Hello everybody,
I’m comparatively new to Go (coming from a backend-leaning full-stack background) and simply pushed the primary public launch of NetDisk, a self-hosted file server I’ve been constructing:
To be upfront about the way it was constructed: I used AI coding instruments to assist scaffold the preliminary model and iterate on components of it, then went again via the core modules to audit safety boundaries, harden transactions, and clear up the construction earlier than placing it out right here. Now I’d actually respect blunt, idiomatic Go suggestions from skilled Gophers.
Fast overview of the stack
- Router & HTTP:
internet/http+chi/v5, embedded vanilla HTML/CSS/JS frontend (embed) - DB: PostgreSQL through
pgx/v5with uncooked SQL and embedded migrations - Storage: Native filesystem and S3-compatible (
minio-go/v7) behind a sharedstorage.Storageinterface - Options: Streaming multipart + chunked uploads, content-addressed blob deduplication & GC queue, Vary/206 downloads and safe-MIME previews, streaming folder ZIP downloads, P2P switch, and an experimental user-space NFS gateway (
willscott/go-nfs+go-billy)
What I’d love critique on
If in case you have a couple of minutes to poke round, these are the areas I’m least assured about:
- Bundle structure & abstractions (
cmd/server/most important.go,inner/): I break up issues intohandler -> service -> repository -> storage. Does this really feel clear and idiomatic in Go, or unnecessarily heavy for a single-binary app of this measurement? - Streaming I/O & cancellation (
inner/storage/native.go,inner/handler/recordsdata.go,OpenZipininner/service/recordsdata.go): Uploads stream viar.MultipartReader()into temp recordsdata with simultaneous SHA-256 hashing (io.MultiWriter) and atomic rename; folder downloads stream ZIPs overio.Pipe. Are there refined goroutine leaks, backpressure points, or edge circumstances on shopper disconnect that I missed? - Transactions & blob GC races (
inner/service/recordsdata.go,inner/service/uploads.go): I just lately moved the blob + node writes for add, on the spot add, and chunked completion into single DB transactions, with failed object deletes queued for background retry. Does the boundary between gradual storage I/O and DB transactions look sound? - Swish shutdown & experimental NFS (
cmd/server/most important.go,inner/nfsgateway/): Any apparent flaws in how background cleanup employees and the NFS server are wired into sign dealing with and shutdown?
Be at liberty to be direct—even small nitpicks on error dealing with, naming, or non-idiomatic patterns are tremendous useful. Thanks for having a look!
A probable edge case within the ZIP path: on shopper disconnect, be sure that the handler closes the reader facet promptly and the producer treats any write error as terminal. If the producer can block on a pipe write whereas the buyer has already returned, that goroutine can leak. Even have the producer choose on the request context between chunks, and clear up temp recordsdata on each error path. A bounded semaphore round concurrent ZIP technology is value contemplating so just a few gradual downloads can’t pin unbounded goroutines or CPU.
Thanks for the assessment!
On the primary couple of factors: downloadZip does defer z.Content material.Shut() so a shopper disconnect closes the pipe reader and unblocks the producer with a write error, and OpenZip streams instantly via io.Pipe with out creating temp recordsdata.
That stated, you caught two actual gaps:
- I presently solely verify
ctx.Err()between recordsdata inwriteZipEntries, not mid-file throughoutio.Copy. - There’s no concurrency certain on ZIP technology in any respect—including a bounded semaphore (and rejecting/ready cleanly when saturated) makes numerous sense so gradual downloads can’t pin CPU/goroutines.
I’ll add the bounded semaphore and mid-stream context verify within the subsequent cross. Respect the suggestions!

