Advice for writing enterprise-level API in Go?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/learngolang

Our great sponsors
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • viper

    Go configuration with fangs

    For configs, given you haven't mentioned what sort of configs - I'd generally recommend viper.

  • Testify

    A toolkit with common assertions and mocks that plays nicely with the standard library

    I haven't needed to use anything outside the standard library for testing - the only exception to this being testify, which I use for the easy assert.Equal and other wrappers most of the time.

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

  • node-config

    Node.js Application Configuration

    How do I handle configs? In our Node APIs we use this config package, which allows us to override default configs on a per-environment basis. What's the standard way of doing this in Go?

  • zerolog

    Zero Allocation JSON Logger

    For #2 I use zerolog, which logs as JSON lines, but gives you considerable control over the output. The standard package is fine if you just want regular ol' text logs, however

  • zap

    Blazing fast, structured, leveled logging in Go.

    I use zap for logging. With some planning, you can easily switch between logging to JSON or Plaintext (the former is faster but less readable). Though, that comes with a learning curve - you'll have to spend some time reading the docs before you can actually start using zap in production. On the other hand, logrus is pretty simple to use, but relatively quite slow (this might not matter for personal projects, but probably will in production). And of course, there's the standard package as well! Take your pick ;)

  • logrus

    Structured, pluggable logging for Go.

    I use zap for logging. With some planning, you can easily switch between logging to JSON or Plaintext (the former is faster but less readable). Though, that comes with a learning curve - you'll have to spend some time reading the docs before you can actually start using zap in production. On the other hand, logrus is pretty simple to use, but relatively quite slow (this might not matter for personal projects, but probably will in production). And of course, there's the standard package as well! Take your pick ;)

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