]> arthur.barton.de Git - ax-zsh.git/commitdiff
New "go" plugin
authorAlexander Barton <alex@barton.de>
Tue, 7 Aug 2018 12:16:28 +0000 (14:16 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 7 Aug 2018 12:16:58 +0000 (14:16 +0200)
plugins/go/README.md [new file with mode: 0644]
plugins/go/go.zprofile [new file with mode: 0644]

diff --git a/plugins/go/README.md b/plugins/go/README.md
new file mode 100644 (file)
index 0000000..f8e8a06
--- /dev/null
@@ -0,0 +1,9 @@
+## go
+
+Enable ZSH *Go* integration:
+
+1. Setup GOPATH and PATH.
+
+### Environment
+
+- `$GOPATH`: Go "workspace" directory.
diff --git a/plugins/go/go.zprofile b/plugins/go/go.zprofile
new file mode 100644 (file)
index 0000000..c3e1718
--- /dev/null
@@ -0,0 +1,25 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# go.zprofile: Setup Go environment.
+
+# Make sure that "go(1)" is installed
+(( $+commands[go] )) || return
+
+# Try to detect existing GOPATH directory ...
+if [[ -z "$GOPATH" ]]; then
+       for gopath in $HOME/.go $HOME/go; do
+               if [[ -d "$gopath" ]]; then
+                       GOPATH="$gopath"
+                       break
+               fi
+       done
+       unset gopath
+fi
+
+# Make sure a GOPATH directory exists:
+if [[ -z "$GOPATH" ]]; then
+       GOPATH="$HOME/.go"
+       mkdir -p "$GOPATH"
+fi
+
+path+=("$GOPATH/bin")
+export GOPATH