I write HTTP services in Go after 13 years (Mat Ryer, 2024)

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • picoshare

    A minimalist, easy-to-host service for sharing images and other files

  • Not OP, but I design my Go projects with a very similar pattern that I learned from OP's 2018 post.

    I think this is a pretty good example of a real-world implementation:

    https://github.com/mtlynch/picoshare

    Particularly these files:

    https://github.com/mtlynch/picoshare/blob/2cd9979dab084ca781...

    https://github.com/mtlynch/picoshare/blob/2cd9979dab084ca781...

  • ogen

    OpenAPI v3 code generator for go

  • https://github.com/ogen-go/ogen

    Write openapi definition, it'll do routing, definition of structs, validation of JSON schemas, etc.

    All I need to do is implement the service.

    Validating an integer range for a querystring parameter is just too boring. And too easy to mistype when writing it manually.

    Anyways, so far only been playing, so haven't found the bad parts yet.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • zanzibar

    A build system & configuration system to generate versioned API gateways.

  • I wrote a static config class that reads configuration for the entire app / server from a JSON or YAML file ( https://github.com/uber/zanzibar/blob/master/runtime/static_... ).

    Once you've loaded it and mutated it for testing purposes or for copying from ENV vars into the config, you can then freeze it before passing it down to all your app level code.

    Having this wrapper object that can be frozen and has a `get()` method to read JSON like data make it effectively not mutable.

  • fx

    A dependency injection based application framework for Go. (by uber-go)

  • I found fx(https://github.com/uber-go/fx) to be a super simple yet versatile tool to design my application around.

    All the advice in the article is still helpful, but it takes the "how do I make sure X is initialized when Y needs it" part completely out of the equation and reduces it from an N*M problem to an N problem, ie I only have to worry about how to initialize individual pieces, not about how to synchronize initialization between them.

    I've used quite a few dependency injection libraries in various languages over the years (and implemented a couple myself) and the simplicity and versatility of fx makes it my favorite so far.

  • PhotoPrism

    AI-Powered Photos App for the Decentralized Web 🌈💎✨

  • out of curiosity, why no sort-of-established pkg and internal dirs? What do you think of https://github.com/photoprism/photoprism structure?

  • guide

    The Uber Go Style Guide.

  • huma

    A modern, simple, fast & flexible micro framework for building HTTP REST/RPC APIs in Go backed by OpenAPI 3 and JSON Schema.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • rest

    Web services with OpenAPI and JSON Schema done quick in Go (by swaggest)

  • go-exhaustruct

    golang analyzer that finds structures with uninitialized fields

  • Because go doesn’t have exhaustiveness checking when initialising structs. Instead it encourages “make the zero value meaningful” which is not always possible not desirable. I usually use a linter to catch this kind of problem https://github.com/GaijinEntertainment/go-exhaustruct

  • zod

    TypeScript-first schema validation with static type inference

  • So far I like the commonly used approach in the Typescript community best:

    1. Create your Schema using https://zod.dev or https://github.com/sinclairzx81/typebox

    2. Generate your Types from the schema. It's very simple to create partial or composite types, e.g. UpdateModel, InsertModels, Arrays of them, etc.

    3. Most modern Frameworks have first class support for validation, like is a great example Fastify (with typebox). Just reuse your schema definition.

    That is very easy, obvious and effective.

  • typebox

    Json Schema Type Builder with Static Type Resolution for TypeScript

  • So far I like the commonly used approach in the Typescript community best:

    1. Create your Schema using https://zod.dev or https://github.com/sinclairzx81/typebox

    2. Generate your Types from the schema. It's very simple to create partial or composite types, e.g. UpdateModel, InsertModels, Arrays of them, etc.

    3. Most modern Frameworks have first class support for validation, like is a great example Fastify (with typebox). Just reuse your schema definition.

    That is very easy, obvious and effective.

  • grpc-gateway

    gRPC to JSON proxy generator following the gRPC HTTP spec

  • it lacks flexibility but i really enjoy grpc-gateway for 99% of my work

    https://github.com/grpc-ecosystem/grpc-gateway

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts