Configure Vscode Golang debugger on Mac DLV

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

First, generate a code signing certificate

1 "Keychain Access" open
2 Open Menu Keychain Access/Certificate Assistant/Create Certificate ...
3 Name: Dlv-cert identity Type: Self-signed certificate certificate type: Code signing and select "Let me override these defaults"
4 Click "Continue", validity period (days): 365 Here you can modify yourself, I changed to 3650
51 way to continue until you see the "Specify a location for this certificate" keychain select System and click the Create button
6 after rebooting the system, then turn on Keychain Access and select System to see the created "Dlv-cert" certificate.
7 Right-click "Dlv-cert" certificate, select "Show Info", "trust", "code signing" modified to: Always trust

Second, install the debugger DLV

sudo go get-u github.com/derekparker/delve/cmd/dlv

After installation, a executable file named DLV is generated in the $gobin directory and moved to the $goroot/bin directory

Third, to the debugger signature, signed after the restart.

Because debugging code under the MAC needs to sign the debugger, some errors are reported.

sudo codesign-s "Dlv-cert" $GOROOT/bin/dlv

Any problems during the step, please restart the computer

Iv. Configuration Item Launch.json (menu: Debug-open configuration)

There are 2 main configurations to be configured, program is the target file location, and args is the run-time parameter. After the configuration is saved, press F5 to be happy to debug. In addition, if there is a problem, add "backend": "native", note the correctness of the file JSON format

    "version": "0.2.0",    "configurations": [        {            "name": "Launch",            "type": "go",            "request": "launch",            "mode": "debug",            "remotePath": "",            "port": 2345,            "host": "127.0.0.1",            "program": "${workspaceRoot}/cmd/cooper",            "env": {},            "args": ["-config=/Users/Fred/go/bin/cooper.toml", "-res=/Users/Fred/go/bin/res"],            "showLog": true,            "backend":"native"        }    ]}

PS: Pro supports my creations. If you have any questions, you can ask me.


Img_1101.jpg

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.