1

Everytime I open a golang file and start editing, (even a file with just the following in)

package models

import "github.com/gofrs/uuid"

type Client struct {
    ID            uuid.UUID `db:"id"`
    Name          string    `db:"name"`
}

... emacs will slow down to a crawl, eventually freezing my entire PC. If I'm lucky I can quickly open a terminal and do xkill, most of the time I have to hard-reset my PC.

Right now, this is only happening with Go files, and I'm forced to use VSCode just to get work and deadlines done.

I'm using

GNU Emacs 28.1

I'm using doom emacs, with the following plugins:

;;; init.el -*- lexical-binding: t; -*-

(doom! :input

       :completion
       company           ; the ultimate code completion backend
       ivy               ; a search engine for love and life

       :ui
       doom              ; what makes DOOM look the way it does
       doom-dashboard    ; a nifty splash screen for Emacs
       doom-quit         ; DOOM quit-message prompts when you quit Emacs
       fill-column       ; a `fill-column' indicator
       hl-todo           ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
       hydra
       modeline          ; snazzy, Atom-inspired modeline, plus API
       nav-flash         ; blink the current line after jumping
       ophints           ; highlight the region an operation acts on
       (popup +defaults)   ; tame sudden yet inevitable temporary windows
       ligatures         ; ligatures or substitute text with pretty symbols
       treemacs          ; a project drawer, like neotree but cooler
       vc-gutter         ; vcs diff in the fringe
       vi-tilde-fringe   ; fringe tildes to mark beyond EOB
       window-select     ; visually switch windows
       workspaces        ; tab emulation, persistence & separate workspaces

       :editor
       (evil +everywhere); come to the dark side, we have cookies
       file-templates    ; auto-snippets for empty files
       multiple-cursors  ; editing in many places at once
       snippets          ; my elves. They type so I don't have to
       word-wrap         ; soft wrapping with language-aware indent

       :emacs
       dired             ; making dired pretty [functional]
       electric          ; smarter, keyword-based electric-indent
       vc                ; version-control and Emacs, sitting in a tree

       :term
       eshell            ; a consistent, cross-platform shell (WIP)

       :checkers
       syntax              ; tasing you for every semicolon you forget
       spell             ; tasing you for misspelling mispelling
       grammar           ; tasing grammar mistake every you make

       :tools
       ansible
       docker
       editorconfig      ; let someone else argue about tabs vs spaces
       (eval +overlay)     ; run code, run (also, repls)
       lookup              ; navigate your code and its documentation
       magit             ; a git porcelain for Emacs

       :lang
       data              ; config/data formats
       elm               ; care for a cup of TEA?
       emacs-lisp        ; drown in parentheses
       go                ; the hipster dialect
       lsp
       (go +lsp)
       (haskell +dante)  ; a language that's lazier than I am
       javascript        ; all(hope(abandon(ye(who(enter(here))))))
       markdown          ; writing docs for people to ignore
       org               ; organize your plain life in plain text
       python            ; beautiful is better than ugly
       sh                ; she sells {ba,z,fi}sh shells on the C xor
       web               ; the tubes

       :email

       :app

       :config

       (default +bindings +smartparens))

EDIT/UPDATE

It looks like flycheck might be the culprit, whenever it tries to check the file it consumes all resources on my machine. Sometimes it will "pause" itself, where I then have a brief moment to quickly kill the window.

I also disabled flycheck for go files only, and then I'm able to edit everything as normal. But then I miss out on the checking and formatting features.

Drew
  • 75,699
  • 9
  • 109
  • 225
Andre
  • 151
  • 4

2 Answers2

1

OK, turns out the issue was not directly related to Emacs.

What was causing the crash was golangci-lint. That application was crashing because it was a very old version, incompatible with my go version. I installed the new version and everything was sorted.

Andre
  • 151
  • 4
0

I am not an expert on doom emacs configuration, but it seems to me that lsp-mode is not enabled. Without lsp-mode, go-mode uses godef which does not work very well with go modules, https://github.com/rogpeppe/godef/issues/114

vpxyz
  • 1
  • Thx. I tried adding lsp-mode and also added `(go +lsp)` to my tools. Unfortunately this still doesn't resolve the issue. I added some update notes to my original post. Looks like Flycheck might be to blame. – Andre May 18 '22 at 10:51