-3

This is my directory structure:

root
├── LICENSE
├── README.md
├── acceptor.go
├── cmd
│   ├── main
│   └── main.go
├── go.mod

I want to debug cmd/main.

I tried: dlv debug main.

I got an error:

package main is not in GOROOT (/usr/local/Cellar/go/1.15.5/libexec/src/main)
exit status 1

How to fix this?

nz_21
  • 6,140
  • 7
  • 34
  • 80

1 Answers1

5

When you call dlv debug main, you're telling delve to debug a package called main in the standard library, which obviously doesn't exist.

You must provide the full absolute, or relative path.

Absolute path:

dlv debug github.com/yourusername/root/cmd

Relative path:

dlv debug ./cmd
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189