lloiser / go-debug

🐛 A go debugger for atom using delve.
https://atom.io/packages/go-debug
MIT License
388 stars 21 forks source link

Bee Framework #142

Closed rgomids closed 6 years ago

rgomids commented 6 years ago

Hi. I have an application runing with Bee. I want to kown how debug using this (go-debug).

rafael@jarvis:~/go/src/medicos$ bee version
______
| ___ \
| |_/ /  ___   ___
| ___ \ / _ \ / _ \
| |_/ /|  __/|  __/
\____/  \___| \___| v1.9.1

├── Beego     : 1.9.2
├── GoVersion : go1.9.2
├── GOOS      : linux
├── GOARCH    : amd64
├── NumCPU    : 4
├── GOPATH    : /home/rafael/go
├── GOROOT    : /usr/local/go
├── Compiler  : gc
└── Date      : Thursday, 19 Jul 2018

To start my server (and run GoLang code) I need put bee run. Bee has a debug tool using Delve too is called using bee dlv.

Thank You all...

lloiser commented 6 years ago

I have no experience with bee so here are 2 possibilities I guess:

  1. just use the Debug option in go-debug. It's a go app so it probably should work...
  2. reading the source code of bee dlv shows the following: https://github.com/beego/bee/blob/f728b23527b11a70d1ac603603f2d649c02a26ef/cmd/commands/dlv/dlv_amd64.go#L148-L155 It creates a headless server that allows multiple connections, so you should be possible to attach to using the following config:
    {
    "name": "bee dlv",
    "mode": "remote",
    "host": "127.0.0.1",
    "port": 8181
    }

Read https://github.com/lloiser/go-debug#configuration if you don't know how add custom configs

rgomids commented 6 years ago

Thanks man. I've tried run the Debug

The Output:

Starting delve with config "Debug"
Running delve with:
Dlv path: /home/rafael/go/bin/dlv
Arguments: debug --headless=true --listen=localhost:2345 --api-version=2 --backend=default
CWD: /home/rafael/go/src/medicos
 Environment: (...)
Delve output: # medicos
./clients.go:13:17: user.Permission undefined (type *usersManager.User has no field or method Permission)
./controller.go:162:68: cannot use c.dataBaseUser (type *dbUser) as type usersManager.UserDataBase in argument to c.UsersMan.AuthenticateUser:
    *dbUser does not implement usersManager.UserDataBase (missing GetUserId method)
        have GetUserID(int) *sql.Row
        want GetUserId(int) *sql.Row
./controller.go:170:31: cannot use c.dataBaseUser (type *dbUser) as type usersManager.UserDataBase in argument to c.UsersMan.GetUser:
    *dbUser does not implement usersManager.UserDataBase (missing GetUserId method)
        have GetUserID(int) *sql.Row
        want GetUserId(int) *sql.Row
./controller.go:171:3: u.SetPermission undefined (type *usersManager.User has no field or method SetPermission)
./controller.go:172:6: u.IDClient undefined (type *usersManager.User has no field or method IDClient, but does have IdClient)
./controller.go:174:4: u.SetConfig undefined (type *usersManager.User has no field or method SetConfig)
./controller.go:174:37: u.IDClient undefined (type *usersManager.User has no field or method IDClient, but does have IdClient)
./controller.go:177:4: u.SetConfig undefined (type *usersManager.User has no field or method SetConfig)
./controller.go:183:34: u.IDClient undefined (type *usersManager.User has no field or method IDClient, but does have IdClient)
./controller.go:199:13: c.UsersMan.DeleteUser undefined (type *usersManager.Users has no field or method DeleteUser)
./controller.go:199:13: too many errors
Delve output: exit status 2
delve closed with code 1
Failed to start delve with config "Debug"
  Error: Error: Closed with code 1

I'm searching an answer about this:

has no field or method Permission

Running the binary with ./medicos don't show any problem

About configuration, I'm trying now. I saved a file conf.json inside my project folder. But when I try run, output is the same.

rgomids commented 6 years ago

We found a lot of errors in project structure. And one of these errors was related to the malfunction of the debug.

In another project, I just start the debug in package main and it work

Thank you for your help!