VSCode Container: [verbose] debugger printing input/output error on all breakpoints

69 Views Asked by At

I'm working on a project where I need to use Ubuntu Focal (20.04)(FROM ubuntu:20.04) as my base image. I'm then installing Golang, along with delve and gopls, all of this within VSCode and a dev container.

The container boots up fine but the problem is with the debugger when I try to debug via my launch.json. I am manually setting the platform in the docker-compose to be platform: linux/amd64. If I don't do this, debugger works just fine, but I can't do this since I need to execute a separate file within the project (requiring amd64).

When I hit "Run and Debug" in VSCode, I can see the prints I've placed within my main.go function, but the breakpoints don't hit.

Dockerfile

FROM ubuntu:20.04
WORKDIR /app

RUN apt-get update && apt-get install -y \
    wget \
    git \
    unzip \
    build-essential

# Golang
COPY --from=golang:latest /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64

ARG GOPLS_VERSION=v0.14.2
ARG DLV_VERSION=latest
RUN go install -v golang.org/x/tools/gopls@${GOPLS_VERSION} \
 && go install -v github.com/go-delve/delve/cmd/dlv@${DLV_VERSION}

COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN go build -o main .

EXPOSE 9080
CMD ["./main"]

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
            "name": "Run",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceFolder}",
            "trace": "verbose",
            "showLog": true,
            "logOutput": "dap",
    ]
}

Error

2024-02-23T19:47:05Z debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":false,"message":"input/output error"}]}}
0

There are 0 best solutions below