emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/go-mode b2837e7 345/495: cmd/oracle: expect oracle binary


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode b2837e7 345/495: cmd/oracle: expect oracle binary beneath $GOBIN, $GOPATH/bin, or $GOROOT/bin
Date: Sat, 7 Aug 2021 09:05:45 -0400 (EDT)

branch: elpa/go-mode
commit b2837e79820e5852ad93fa4b1701603ff11002b6
Author: Alan Donovan <adonovan@google.com>
Commit: Dominik Honnef <dominik@honnef.co>

    cmd/oracle: expect oracle binary beneath $GOBIN, $GOPATH/bin, or $GOROOT/bin
    
    in that order, so that "go get golang.org/x/tools/cmd/oracle" installs
    it and no copy is needed.  We keep the old location for compatibility.
    
    Why is if/else control flow so hard in basic Lisp?  Sometimes you just need 
'return'.
    
    Change-Id: Iae231a761d707daaa1316161cfad0365111eff0e
    Reviewed-on: https://go-review.googlesource.com/9547
    Reviewed-by: David Chase <drchase@google.com>
---
 guru_import/cmd/oracle/oracle.el | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/guru_import/cmd/oracle/oracle.el b/guru_import/cmd/oracle/oracle.el
index 825eee1..c1fb08e 100644
--- a/guru_import/cmd/oracle/oracle.el
+++ b/guru_import/cmd/oracle/oracle.el
@@ -22,8 +22,25 @@
   "Options specific to the Go oracle."
   :group 'go)
 
-(defcustom go-oracle-command (concat (car (go-root-and-paths)) "/bin/oracle")
-  "The Go oracle command; the default is $GOROOT/bin/oracle."
+(defcustom go-oracle-command
+  (let* ((dirs (go-root-and-paths))
+         (gopath (cdr dirs))
+         (gobin (getenv "GOBIN"))
+         (goroot-cmd (concat (car dirs) "/bin/oracle"))
+         cmd)
+    (if gobin
+        (let ((gobin-cmd (concat gobin "/oracle")))
+          (if (file-executable-p gobin-cmd)
+              (setq cmd gobin-cmd)))) ; use $GOBIN/oracle if executable
+    (and (null cmd)
+         gopath
+         (let ((gopath-cmd (concat (car gopath) "/bin/oracle")))
+           (if (file-executable-p gopath-cmd)
+               (setq cmd gopath-cmd)))) ; use GOPATH[0]/bin if executable
+    (or cmd goroot-cmd)) ; use $GOROOT/bin by default
+  "The Go oracle command.  The following directories are
+searched: (1) $GOBIN; (2) dir/bin, where dir is the first
+directory on $GOPATH; (3) $GOROOT/bin."
   :type 'string
   :group 'go-oracle)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]