-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-debug-server.sh
More file actions
48 lines (41 loc) · 1.22 KB
/
run-debug-server.sh
File metadata and controls
48 lines (41 loc) · 1.22 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
# !/bin/bash
function install_dlv() {
echo "Installing Delve..."
go install github.com/go-delve/delve/cmd/dlv@latest
if [ $? -ne 0 ]; then
echo "Failed to install Delve. Please check your Go environment."
exit 1
fi
}
debug_server_ip=$(hostname -I | awk '{print $1}')
debug_server_port=2345
pwd=$(pwd)
install_dlv
print_vscode_config() {
cat <<EOF
Copy the following configuration into your .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Connect to Go Debug Server",
"type": "go",
"request": "attach",
"debugAdapter": "dlv-dap", // \`legacy\` by default
"mode": "remote",
"port": $debug_server_port, // remote server port
"host": "$debug_server_ip", // remote server ip
"substitutePath": [
{
"from": "\${workspaceFolder}",
"to": "$pwd" // remote server project path
}
]
}
]
}
EOF
}
print_vscode_config
echo "Starting Delve debug server on port $debug_server_port..."
dlv debug --headless --listen=:$debug_server_port main.go --api-version=2 # --accept-multiclient