baqx0r
baqx0r

Reputation: 125

Cannot set breakpoint in golang packages in Intellij 2020.1

I have a simple web app which has cmd/ and pkg/ folders. As a convention, I'm importing packages in *.go files in cmd folder. Setting breakpoints work fine in any file in cmd but it doesn't work in packages.

Error message is:

could not find statement at <path_to_file>:<line_number>, please use a line with a statement

Project structure I'm using is similar to this in simplified form:

project_root:
- cmd/
    main.go 
- pkg/
    app.go // I set a breakpoint to a function here L:156. it's being called at main.go
    ...
- api/
- config/
...

enter image description here

my build flag has -gcflags "all=-N -l"

Similar issue has been discussed here in the past: IntelliJ 2017.1.2 GOLANG debug does not work on breakpoints in packages

Edit:

Upvotes: 5

Views: 3825

Answers (1)

J.Maxg
J.Maxg

Reputation: 31

Make sure your breakpoint method be used. I meet the same problem like you. And I find my bug (the breakpoint method never be used).

Upvotes: 2

Related Questions