diff --git a/CHANGELOG.develop b/CHANGELOG.develop index cc80002a9..d33779ae0 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -805,6 +805,7 @@ Other: (thanks to Boris Buliga) - Cleanup =which-key= by removing obsolete entries and adding some missing ones (thans to duianto) + - Add =go-run-args= to pass command line arguments to `go run` - Fixed: - Fixed ~h~ key binding in compilation and grep buffers (thanks to Sylvain Benner) @@ -2170,4 +2171,5 @@ Other: Hoffmann, Xiang Ji, Yi Liu, zer09, Zhige Xin) *** Release notes summarized Thanks to: Grant Shangreaux, Songpeng Zu, Igor Almeida, Miciah Dashiel Butler - Masters, Abhishek(Compro) Prasad, Deepak Khidia, Ward Harris, Jiahao Jiang + Masters, Abhishek(Compro) Prasad, Deepak Khidia, Ward Harris, Jiahao Jiang, + Enze Chi diff --git a/layers/+lang/go/README.org b/layers/+lang/go/README.org index 38b5dcb8a..ee1a0b8a5 100644 --- a/layers/+lang/go/README.org +++ b/layers/+lang/go/README.org @@ -153,6 +153,15 @@ or (go :variables gofmt-command "goimports") #+END_SRC +To run current main package with command line arguments, set the value of +=go-run-args= as file local variable, e.g. + +#+BEGIN_SRC emacs-lisp + // Local Variables: + // go-run-args: "--output run.log" + // End: +#+END_SRC + ** Indentation By default, the tab width in Go mode is 8 spaces. To use a different value set the layer variable =go-tab-width=, e.g. diff --git a/layers/+lang/go/config.el b/layers/+lang/go/config.el index 5bba79b3f..8b3e78fb7 100644 --- a/layers/+lang/go/config.el +++ b/layers/+lang/go/config.el @@ -39,3 +39,6 @@ (defvar go-test-verbose nil "Control verbosity of `go test` output") + +(defvar go-run-args "" + "Additional arguments to by supplied to `go run` during runtime.") diff --git a/layers/+lang/go/funcs.el b/layers/+lang/go/funcs.el index a9064f38c..d714c7928 100644 --- a/layers/+lang/go/funcs.el +++ b/layers/+lang/go/funcs.el @@ -115,9 +115,11 @@ (defun spacemacs/go-run-main () (interactive) (shell-command - (format "go run %s" + (format "go run %s %s" (shell-quote-argument (or (file-remote-p (buffer-file-name (buffer-base-buffer)) 'localname) - (buffer-file-name (buffer-base-buffer))))))) + (buffer-file-name (buffer-base-buffer)))) + go-run-args))) + (defun spacemacs/go-packages-gopkgs () "Return a list of all Go packages, using `gopkgs'." (sort (process-lines "gopkgs") #'string<))