-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgofish.fish
67 lines (48 loc) · 1.56 KB
/
gofish.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# GoFish
# A small wrapper for managing golang workspaces
# Namespace can be defined with set -x GOFISH_NAMESPACE
# Current shell use name is the default
if not set -q GOFISH_NAMESPACE
set -g GOFISH_NAMESPACE $USER
end
alias goon acgoworkspace
alias gooff degoworkspace
function mkgoworkspace --description "Create a new golang Workspace"
if [ (count $argv) -lt 1 ]
echo "You need to specify a workspace name"
return 1
end
emit gofish_workspace_will_be_created
set workspace_name $argv[1]
set src_path "src/$GOFISH_NAMESPACE/$workspace_name"
# creating standard directories
test -e "bin" ; and mkdir "bin"
mkdir -p $src_path
test -e "pkg" ; and mkdir "pkg"
touch "$src_path/main.go"
emit gofish_workspace_created
acgoworkspace $workspace_name
end
function acgoworkspace --description "Activate a Go Workspace"
if [ (count $argv) -lt 1 ]
echo "You need to specify a workspace name"
return 1
end
set workspace_name $argv[1]
set -x GOFISH_WORKSPACE $workspace_name
echo "src/$GOFISH_NAMESPACE/$workspace_name"
if not [ -d "src/$GOFISH_NAMESPACE/$workspace_name" ]
echo "The Go Workspace '$workspace_name' does not exist in this path"
return 2
end
emit gofish_workspace_will_activate
set -g -x GOPATH "$PWD/"
emit gofish_workspace_activated
end
function degoworkspace --description "Deactivate a go workspace"
emit gofish_workspace_will_deactivate
if set -q GOPATH
set -e GOPATH
end
emit gofish_workspace_deactivated
end