 (defvar go-vendor-buffer-name "*go vendor*"
   "Name of buffer for go test output.")
 
-(defun go/go-tests (args)
-  (interactive)
-  (compilation-start (concat "cd " (projectile-project-root)
-                             " && go test " args)
-                     nil (lambda (n) go-test-buffer-name) nil))
-
-(defun go/go-tests-all ()
-  (interactive)
-  (go/go-tests "./..."))
-
-(defun go/go-tests-all-verbose ()
-  (interactive)
-  (go/go-tests "./... -v"))
+(defun go/spawn (cmd buf-name)
+  (compilation-start cmd nil (lambda (_n) buf-name)))
+
+(defun go/go-test-current-pkg ()
+  (interactive)
+  (go/spawn "go test" go-test-buffer-name))
+
+(defun go/go-test-root ()
+  (interactive)
+  (let ((cmd (format "cd %s; go test ./..." (projectile-project-root))))
+    (go/spawn cmd go-test-buffer-name)))
+
+(defun go/go-test-run (test-name)
+  (interactive (list (read-string "Test name: ")))
+  (let ((cmd
+         (format "cd %s; go test -run %s ./..."
+                 (projectile-project-root)
+                 test-name)))
+    (go/spawn cmd go-test-buffer-name)))
 
 (defun go/go-vendor ()
   (interactive)
-  (compilation-start (concat "cd " (projectile-project-root)
-                             " && go mod vendor")
-                     nil (lambda (n) go-vendor-buffer-name) nil))
+  (let ((cmd (format "cd %s; go mod vendor" (projectile-project-root))))
+    (go/spawn cmd go-vendor-buffer-name)))
 
 ;; Haskell
 

;; Language configuration.

;;; Code:

(use-package go-mode
  :straight t


(core/local 'go-mode-map
            "rn" 'lsp-rename
            "tt" 'go/go-test-current-pkg
            "tp" 'go/go-test-root
            "ti" 'go/go-test-run
            "v" 'go/go-vendor)

(defvar go-test-buffer-name "*go test*"
