branch: elpa/go-mode
commit 965dcbc5eb06d73cb700724535dd449a00082b84
Author: Dominik Honnef <[email protected]>
Commit: Dominik Honnef <[email protected]>

    Use file name, not directory, with -srcdir flag
    
    goimports accepts a full file name for srcdir, and requires it for some
    of its features.
    
    Closes gh-146
---
 go-mode.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index cc6422b..b2a8bd0 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1152,7 +1152,11 @@ with goflymake \(see URL 
`https://github.com/dougm/goflymake'), gocode
           (when (and (gofmt--is-goimports-p) buffer-file-name)
             (setq our-gofmt-args
                   (append our-gofmt-args
-                          (list "-srcdir" (file-name-directory (file-truename 
buffer-file-name))))))
+                          ;; srcdir, despite its name, supports
+                          ;; accepting a full path, and some features
+                          ;; of goimports rely on knowing the full
+                          ;; name.
+                          (list "-srcdir" (file-truename buffer-file-name)))))
           (setq our-gofmt-args (append our-gofmt-args
                                        gofmt-args
                                        (list "-w" tmpfile)))

Reply via email to