Debugging Golang programs with delve

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Installing delve

The official documentation is already full, refer to this (GitHub) installation. Mac OSX is a hassle and needs to get the certificate done.

Breakpoints and variable printing

After the delve is installed, you can use the DLV command directly at the command line.

To view available commands

dlv -h

See Help information: Support for debugging a running process with DLV attach, supporting DLV connect to network port debugging. Here first debug with the simplest DLV Debug.

dlv debug main.go

It then goes into debug mode, at which point the help can see the supported commands.

(dlv) b main.go:16 #在 main.go 的第 16 行设置断点。(dlv) bp   #查看当前所有断点(dlv) c    #运行到下一个断点或者程序结尾(dlv) p a  #打印变量 a 的值(dlv) n    #单步执行代码(dlv) set a=1  #设置变量a 的值
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.