Last active
September 10, 2015 14:24
-
-
Save danp/c4f3d146ae4027a69bc1 to your computer and use it in GitHub Desktop.
godep-aware goimports and more
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# for use with emacs/vim/etc as goimports and goflymake | |
# | |
# I use it with config like: | |
# | |
# (setenv "GOPATH" (expand-file-name "~/Projects/go")) | |
# (setenv "PATH" "~/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/Projects/go/bin:/usr/local/go/bin") | |
# (setq exec-path (append exec-path (list (expand-file-name "~/Projects/go/bin") "/usr/local/go/bin"))) | |
# | |
# and put this script as `goimports` in ~/bin + symlink `goflymake` to it | |
# with the real `goimports` and `goflymake` in $GOPATH/bin | |
if [ -z "$GOPATH" ]; then | |
echo "Missing GOPATH" >&2 | |
exit 1 | |
fi | |
orig_gopath="$GOPATH" | |
godep_path=$(godep path 2>/dev/null) | |
if [ $? -eq 0 ]; then | |
export GOPATH="$godep_path:$orig_gopath" | |
fi | |
exec "$orig_gopath/bin/$(basename "$0")" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment