What are your strategies to prevent nil pointers errors in your code base?

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

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.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • gofuzz

    Discontinued Fuzz testing for go.

  • Also, with some of the fuzzers available, you can actually generate structs and specify the nil chance like https://github.com/google/gofuzz

  • go-tools

    Staticcheck - The advanced Go linter

  • Unfortunately I don't know of any tools that can/do always detect it. There's this discussion for the staticcheck linter where they basically don't think it's worth false positives in order to support it a lint for it.

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

    Package truthy provides truthy condition testing with Go generics (by earthboundkid)

  • I personally always make sure that, if I have a function that creates the struct, I define all of the fields. When I don't a) have control over that or b) have a function to init the struct, I typically end up using a new package called truthy that is built on generics and tells me the truthy value of the variable, kind of like Boolean(value) in javascript.

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

  • Gopher Pythonista #1: Moving From Python To Go

    3 projects | dev.to | 27 Jul 2023
  • Fuzzing in Go

    2 projects | /r/golang | 10 Jun 2023
  • Go Fuzz Testing – The Basics

    2 projects | news.ycombinator.com | 29 Mar 2022
  • naive question regarding Fuzz testing de/serialisation

    2 projects | /r/golang | 21 Mar 2022
  • Fun with Go generics: a package to add truthy conditionals

    1 project | news.ycombinator.com | 11 Oct 2021