-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo.sh
More file actions
64 lines (53 loc) · 1.58 KB
/
go.sh
File metadata and controls
64 lines (53 loc) · 1.58 KB
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
#!/usr/bin/env bash
set -euo pipefail
provision_setup_go() {
cat >>~/.shell_aliases <<"EOF"
export PATH="$HOME/.local/go/bin:$PATH"
if type go >/dev/null 2>&1; then
export GOPATH="$HOME/.go-workspace"
export GO15VENDOREXPERIMENT=1
export PATH="$PATH:$GOPATH/bin"
if [ -n "$(find ~/.go-workspace/pkg/mod/golang.org/x/tools/ 2>/dev/null | grep gopls || true)" ]; then
(cd ~ && go install golang.org/x/tools/gopls@latest)
fi
fi
if type buf >/dev/null 2>&1 && [ ! -f ~/.completions/buf.zsh ]; then
buf completion zsh >~/.completions/buf.zsh
fi
EOF
cat >>~/.zshrc <<"EOF"
if [ -f ~/.completions/buf.zsh ]; then
source ~/.completions/buf.zsh
fi
EOF
cat >>~/.shell_aliases <<"EOF"
if type go >/dev/null 2>&1; then
alias gmt='go mod tidy'
alias DlvAllowLinux='echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope'
alias GoInstallGorun='go install github.com/erning/gorun@latest'
alias GoInstallDelve='go install github.com/go-delve/delve/cmd/dlv@latest'
alias GoInstallProtocGenGo='go install google.golang.org/protobuf/cmd/protoc-gen-go@latest'
fi
EOF
cat >>~/.vimrc <<"EOF"
if executable('go')
let g:go_def_mapping_enabled = 0
let g:go_doc_keywordprg_enabled = 0
autocmd filetype go vnoremap <leader>kk "iyOfmt.Println("a", a);<c-c>6hidebug: <c-r>=expand('%:t')<cr>: <c-c>lv"ipf"lllv"ip
endif
EOF
cat >>~/.vim/lua/entry.lua <<"EOF"
if vim.fn.executable('go') == 1 then
require('dap-go').setup {
dap_configurations = {
{
type = "go",
name = "Attach remote",
mode = "remote",
request = "attach",
},
},
}
end
EOF
}