How to use dlv debug with multiple versions of Go

168 views
Skip to first unread message

Vinoth Ramiah

unread,
Aug 25, 2019, 7:34:19 PM8/25/19
to delve-dev
Is it possible to specify to dlv to use an alternate version of Go other than the default one found in $PATH? 

I need to use go1.11 for a specific project, so followed this guide (https://golang.org/doc/install#extra_versions) to get go1.11 installed alongside go1.12. As go1.12 is the default though, dlv debug uses it to build the binary instead. Is it possible to override this?

Thanks

Vinoth Ramiah

unread,
Aug 30, 2019, 11:43:05 AM8/30/19
to Alessandro Arzilli, delve-dev
Thanks for getting back to me Alessandro. 

Figured out that I can set GOROOT to the directory where the alternate go version is located (~/sdk/go1.11.5), and making sure PATH includes ~/sdk/go1.11.5/bin before the standard go bin path. Delve then uses it to debug instead of default go binary. Bit clunky but it works 👍

Alessandro Arzilli

unread,
Aug 30, 2019, 7:39:23 PM8/30/19
to Vinoth Ramiah, delve-dev
We don't have an option for that but you can pass -gcflags='all=-N
-l' to 'go build' and then debug the resulting executable with
'dlv exec'
> --
> You received this message because you are subscribed to the Google Groups "delve-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to delve-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/delve-dev/c770bb84-ba3c-405b-a998-c2633d22469a%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages