Add Go command variables

This is a squash commit, it includes:
* Add go run and go test command variables
* Update go README for go-run-command and go-test-command
* Update CHANGELOG
This commit is contained in:
Jay Z 2020-06-10 18:12:56 -04:00 committed by GitHub
parent ff5389160b
commit 34a446724f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 2 deletions

View File

@ -2000,6 +2000,8 @@ Other:
- Make flycheck disable checkers covered by golangci (thanks to zhuoyikang)
- Updated build instructions for =golangci-lint= (thanks to pancho horrillo)
- Added =dap-go= integration (ljupchokotev)
- Added =go-run-command= variable (thanks to Jay Z)
- Added =go-test-command= variable (thanks to Jay Z)
- Key bindings
- =godoctor= key bindings (thanks to TinySong and Eivind Fonn):
- ~SPC m r n~ to rename

View File

@ -104,6 +104,14 @@ layers are enabled as well.
* Configuration
** Execution
By default, the go run command is =go run=. If you want to use a different
command or run with environment variables, set the layer variable
=go-run-command=.
#+BEGIN_SRC emacs-lisp
(go :variables go-run-command "ENV_VAR=foo go run")
#+END_SRC
To run the current =main= package with command line arguments, set the value of
=go-run-args= as a file local variable, e.g.
@ -174,6 +182,14 @@ Tests are run in a compilation buffer displayed in a popup window that can be
closed by pressing ~C-g~ from any other window. The variable =go-test-buffer-name=
can be customized to set the output buffer name.
By default, the go test command is =go test=. If you want to use a different
command or test with environment variables, set the layer variable
=go-test-command=.
#+BEGIN_SRC emacs-lisp
(go :variables go-test-command "ENV_VAR=foo go test")
#+END_SRC
To provide additional arguments to =go test=, specify =go-use-test-args=.
#+BEGIN_SRC emacs-lisp

View File

@ -44,3 +44,9 @@ If `nil' then `go-mode' is the default backend unless `lsp' layer is used.")
(defvar go-run-args ""
"Additional arguments to by supplied to `go run` during runtime.")
(defvar go-run-command "go run"
"Go run command. Default is `go run`.")
(defvar go-test-command "go test"
"Go test command. Default is `go test`.")

View File

@ -110,7 +110,7 @@
(defun spacemacs/go-run-tests (args)
(interactive)
(compilation-start (concat "go test " (when go-test-verbose "-v ") args " " go-use-test-args)
(compilation-start (concat go-test-command " " (when go-test-verbose "-v ") args " " go-use-test-args)
nil (lambda (n) go-test-buffer-name) nil))
(defun spacemacs/go-run-package-tests ()
@ -148,7 +148,7 @@
(defun spacemacs/go-run-main ()
(interactive)
(shell-command
(format "go run %s %s"
(format (concat go-run-command " %s %s")
(shell-quote-argument (or (file-remote-p (buffer-file-name (buffer-base-buffer)) 'localname)
(buffer-file-name (buffer-base-buffer))))
go-run-args)))