I am trying to set up VS Code with Go, and I am getting an error when attaching the debugger. Since I am brand new to VS Code, I have no leads as to why.
I have installed delve debugger:
go get -u github.com/derekparker/delve/cmd/dlv
delv -v
delv 9.11.3-1ubuntu1.1-Ubuntu
I get this error when I try to attach the debugger to a very simple golang file:
API server listening at: 127.0.0.1:2345
time="2018-08-30T09:39:57-06:00" level=info msg="launching process with args: [/home/craig/Documents/GoLang/src/github.com/mornindew/sharedPackages/email/debug]" layer=debugger
Can not debug non-main package
Process exiting with code: 1
Code:
package email
import "fmt"
// SendEmail - Sends The email
func SendEmail() {
}
func main() {
fmt.Println("Hello World!")
i := 101
fmt.Println(i)
}
This is all very helpful, thank you very much.
It makes me think that I have a problem in my project organization. I have a project that has a bunch of reusable packages. I didn't want to create a github repo for each individual package. Essentially:
package1
-- package1.go
-- package1_test.go
package2
-- package2.go
-- package2_test.go
...
package10
-- package10.go
-- package10_test.go
Is this structured incorrectly? Is there a recommended way to accomplish this?