Best practices regarding init function and small CLI apps

This page summarizes the projects mentioned and recommended in the original post on /r/golang

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

    A blank canvas for your web app, in Go. (by golangdk)

    I usually have my main function be very scriptlike, with all the setup code, env vars and such in the beginning, and then starting whatever needs to be started. I think that's fine. See an example from some of my code here: https://github.com/golangdk/canvas/blob/newsletter-email/cmd/server/main.go

  • viper

    Go configuration with fangs

    I tend to use packages like viper (https://github.com/spf13/viper) to handle configuration at a global level. If you want to do it yourself, you can write a singleton to store your configurations. On the internet there are many examples about writing a singleton in Go.

  • 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.

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