Is possible to debug from terminal (included in GoLand IDE), what I want to do is to stop in a break point when you run a .go file from the terminal. This because I want to run the script sending parameters to go to validate if parameters has been received to the .go script.
Thanks.
Yes, it's possible to debug from GoLand! For me next approach is the best:
1) For example we have x.go
:
package main
import "fmt"
func main() {
name, ending := "World", "!"
ending2 := `)`
fmt.Printf("Hello %s %s%s
", name, ending, ending2)
}
2) Edit your debug configuration:
3) Run in console next command:
go build -gcflags='-N -l' x.go \
&& dlv --listen=:2345 --headless=true --api-version=2 exec ./x
4) Now place your breakpoint and hit "debug" button.
Here you can find video how it looks for me.
You can run the debugger directly from GoLand and it will use Go build then delve to run the application.
However, if you want to use a custom build process for the binary, build it as you normally would, and make sure you specify the -gcflags="all=-N -l"
(if you use Go 1.10+,or drop all=
if you use 1.9 or lower). The launch the binary from terminal and then use "Run| Attach to local process" to attach the debugger to the binary.
Please clarify the question in case this is not what you are looking for.
It's super easy in GoLand
!
1) For example we have x.go
:
package main
import "fmt"
func main() {
name, ending := "World", "!"
ending2 := `)`
fmt.Printf("Hello %s %s%s
", name, ending, ending2)
}
2) Set GOPATH
:
3) Edit your debug configuration. Set Run kind
to directory with purpose to debug all go files in directory:
4) Now place your breakpoint and hit "debug" button.
Here you can find video how it looks for me.