Last active
          July 23, 2021 17:48 
        
      - 
      
- 
        Save psanford/d175c10ca28b1566de358fe336a9fb2f to your computer and use it in GitHub Desktop. 
Revisions
- 
        psanford revised this gist Jul 23, 2021 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,3 +47,11 @@ (switch-to-buffer buffer) (funcall command)))) (add-to-list 'compilation-error-regexp-alist-alist '(go-compilation "\\([^[:space:]\n:]+\\.go\\):\\([0-9]+\\)" 1 2)) (define-compilation-mode go-compilation "Go Compile" "Compilation mode for go" (set (make-local-variable 'compilation-error-regexp-alist) '(go-compilation))) 
- 
        psanford revised this gist Jul 23, 2021 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,3 +27,23 @@ (cons `(lambda () (pms-go-run-test ,more-test-args)) (current-buffer)))))) (defvar pms-previous-test-ring (make-ring 5)) (defun pms-run-last-test (&optional n) "Run most recently run test again" (interactive "P") (when (buffer-file-name) (save-buffer)) (setq n (cond ((null n) 0) ((listp n) 1) (1 n))) (let ((prev (ring-ref pms-previous-test-ring n))) (if (> n 0) (ring-insert pms-previous-test-ring prev)) (let ((command (car prev)) (buffer (cdr prev))) (switch-to-buffer buffer) (funcall command)))) 
- 
        psanford created this gist Jul 23, 2021 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ (defun pms-go-run-test (&optional more-test-args) "Runs tests for current package" (interactive) (when (buffer-file-name) (save-buffer)) (compile (concat "go test -v -count=1 -mod=mod" more-test-args) 'go-compilation) (ring-insert pms-previous-test-ring (cons `(lambda () (pms-go-run-test ,more-test-args)) (current-buffer)))) (defun pms-go-single-test-function (&optional more-test-args) "Runs the current test function only" (interactive) (save-excursion (let ((func-name (go--function-name))) (when (not (string-prefix-p "Test" func-name)) (error "Not in a test function: %s" func-name)) (compile (concat "go test -v -count=1 -mod=mod -run ^" func-name "$" more-test-args) 'go-compilation) (ring-insert pms-previous-test-ring (cons `(lambda () (pms-go-run-test ,more-test-args)) (current-buffer))))))