From 8ff1f51a5bdc044fe6282fb3918ce02a8a56fca8 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Thu, 30 Apr 2015 13:44:34 -0400 Subject: [PATCH] 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 --- cmd/oracle/oracle.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/oracle/oracle.el b/cmd/oracle/oracle.el index 825eee19..c1fb08e1 100644 --- a/cmd/oracle/oracle.el +++ b/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)