Skip to content

Instantly share code, notes, and snippets.

@pelletier
Created July 18, 2022 14:49
Show Gist options
  • Save pelletier/548c2f2eb0a297f0231c9ab0111f1c23 to your computer and use it in GitHub Desktop.
Save pelletier/548c2f2eb0a297f0231c9ab0111f1c23 to your computer and use it in GitHub Desktop.
;; Display the assembly generated by the Go compiler of the code at current line in an emacs buffer.
;;
;; Navigate to a line of go code, then M-x my/go-show-asm.
(defun my/go-show-asm ()
(interactive)
(let* ((p (buffer-file-name))
(out-b "*go-show-asm*")
(needle (concat p ":" (number-to-string (line-number-at-pos)))))
(if (string-suffix-p ".go" p)
(progn
(save-buffer)
(shell-command "go build -gcflags -S" nil out-b)
(switch-to-buffer-other-window out-b)
(beginning-of-buffer)
(isearch-forward nil t)
(isearch-yank-string needle))
(message "Cannot operate on a not .go file."))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment