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