You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the main .go files inside the cmd/web folder. The problem is that I have helpers, dbmodels, error handling inside internal. folder too.
vscode starts the app correctly, but as soon as it requires things from internal or other folders in this structure outside /cmd/web it starts getting errors. It's like the packages imports are not working correctly. If I put everything inside the /cmd/web folder I can debug and put breakpoints in the whole app
How do you debug web API's with this structure?
The text was updated successfully, but these errors were encountered:
@adrianescat, try to split debug into build+exec(tasks.json+launch.json) like here, to keep working eviroment for debugging program in project root dir. laucn.json:
package main
import (
"fmt""os"
)
funcmain() {
if_, err:=os.Stat("readme.md"); err==nil { // project's root readmefmt.Println("File exists\n") // <-- works!
} else {
fmt.Println("File does not exist\n")
}
}
debug console:
Starting: C:\Users\...\go\bin\dlv.exe dap --listen=127.0.0.1:60418 from C:\...\<project_dir>
DAP server listening at: 127.0.0.1:60418
Type 'dlv help' for list of commands.
File exists <-- here we see root Readme
Hey! I have installed delve, and is running fine on my PC. I'm trying to use this config in the
launch.json
:I have the main
.go
files inside thecmd/web
folder. The problem is that I have helpers, dbmodels, error handling insideinternal
. folder too.vscode starts the app correctly, but as soon as it requires things from internal or other folders in this structure outside
/cmd/web
it starts getting errors. It's like the packages imports are not working correctly. If I put everything inside the/cmd/web
folder I can debug and put breakpoints in the whole appHow do you debug web API's with this structure?
The text was updated successfully, but these errors were encountered: