Check Go Escape Analysis Result in Emacs

Sometimes, you may need zero heap allocation in extremely critical code path (which is rare).

To do that, you can run benchmark with -benchmem or check Go compiler's escape analysis result.

Showing the result in Emacs is easy, you simply define a flycheck checker:

(flycheck-define-checker goescape
  "Check Go escape analysis result"
  :command ("go" "build" "-gcflags=-m" "./...")
  :modes go-mode
  :error-patterns
  ((error line-start
          (file-name) ":" line ":" column ": "
          (message (+? nonl) " escapes to heap")
          line-end)))

Then you can get the result like this:

You can also do this in VS Code.

Kauruus
CC BY-SA 4.0
Website built with Franklin.jl and the Julia programming language.