Skip to content

Instantly share code, notes, and snippets.

@sashaaro
Last active March 2, 2023 11:04
Show Gist options
  • Save sashaaro/ccd242b87f48dafca614d14fcb3a4381 to your computer and use it in GitHub Desktop.
Save sashaaro/ccd242b87f48dafca614d14fcb3a4381 to your computer and use it in GitHub Desktop.
nvim-dap + debug golang delve + docker compose
local dap = {
adapters = {
go = {
type = "server",
port = 9004,
}
},
configurations = {
go = {
{
type = "go",
name = "delve container debug",
request = "attach",
mode = "remote",
substitutepath = {{
from = "${workspaceFolder}",
to = "/opt/app",
}},
}
},
}
}
services:
debug:
build:
context: .
dockerfile: ./docker/go-delve.Dockerfile
entrypoint: dlv
working_dir: /opt/app
restart: unless-stopped
ports:
- 9004:9004
command:
- "debug"
- "--headless"
- "--listen=:9004"
- "--api-version=2"
- "--accept-multiclient"
- "--log"
#- "--log-output=debugger,rpc,dap"
- "./cmd/myapp"
- "--"
- "-c" # myapp arguments
- "./config.yaml"
volumes:
- ./:/opt/app
FROM golang:1.20
RUN go install github.com/go-delve/delve/cmd/dlv@latest
ENTRYPOINT /go/bin/dlv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment