The cost of Go's panic and recover

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

InfluxDB high-performance time series database
Collect, organize, and act on massive volumes of high-resolution data to power real-time intelligent systems.
influxdata.com
featured
CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
  1. go

    The Go programming language

    > I also like how golang docs literally describe using panics as poor man's exceptions:

    And I like how https://github.com/golang/go/issues/26799 describes that use of panic in the original version of this bog entry from 2010:

    quote:

    However, this is a poor example and a misuse of panic and recover as exceptions. See https://golang.org/doc/effective_go.html#panic

    The example will be invalid soon with the release of go 1.11 as well. The panic/recover was removed from the unmarshal code. See master's

    end quote.

    The blog entry was later changed because this was fixed. It now refers to marshaling which, sadly, sill uses this mechanism.

    The fact that this is still in the json package is a pain point, yes. Does it validate the use of panic as a form of flow control? No. Here is what "Effective Go" has to say about the topic:

    https://go.dev/doc/effective_go#panic

    quote:

    But what if the error is unrecoverable? Sometimes the program simply cannot continue.

    For this purpose, there is a built-in function panic that in effect creates a run-time error that will stop the program (but see the next section).

    end quote.

  2. InfluxDB

    InfluxDB high-performance time series database. Collect, organize, and act on massive volumes of high-resolution data to power real-time intelligent systems.

    InfluxDB logo
  3. chi

    lightweight, idiomatic and composable router for building Go HTTP services

    The only use for me has been to put a recoverer middleware[1] to catch any unhandled panics and return HTTP 500s in my applications.

    [1] https://github.com/go-chi/chi/blob/master/middleware/recover...

  4. kubernetes

    Production-Grade Container Scheduling and Management

    > they are more performant and easier to understand.

    They are more performant because Go decided to make them so. E.g. in Erlang crashing a process is an expected lightweight operation.

    As for "easier to understand"... They are not when:

    - your code is littered with `x, err = ...; if err != nil`

    - it's not easier to understand when the code errors have to be dealt with on a higher/different level. The calling code isn't always the one that needs to deal with all the errors

    Just a very random example (I literally just clicked through random files): https://github.com/kubernetes/kubernetes/blob/master/pkg/con...

    Oh, look, you can't even see the logic behind all the `if err`s which do nothing but return the error to be handled elsewhere.

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

  • Show HN: API Gateway with SQL support, written in Go

    1 project | news.ycombinator.com | 1 Aug 2022
  • Migrating from Rails to Go: Making the Switch with Confidence

    1 project | dev.to | 22 Apr 2025
  • Best Opensource Coding Ai

    4 projects | dev.to | 17 Apr 2025
  • Gerando Pagamentos via Pix com a AbacatePay

    6 projects | dev.to | 16 Apr 2025
  • Show HN: Gleece – Streamlined API development framework for Go

    2 projects | news.ycombinator.com | 7 Apr 2025

Did you know that Go is
the 4th most popular programming language
based on number of references?