DLV, also become delve, is the Go Language source debugging tool. Developed by Derekparker, open source and GitHub. When you configure the Go Language development environment on your Mac, the common problem is that the DLV call is always unsuccessful, cannot start the application, cannot be debugged, and so on. Most of the problems are related to the Mac's security mechanism. Your app is signed with Codesign on your Mac, and programs that don't have a signature are subject to some limitations, such as being unable to act as a debugger.
There are two ways to install delve:
Premise
To install the Xcode command-line tool, run the following command to install:
$ xcode-select --install
Otherwise, the following error will occur:
Could not launch process:exec: ' lldb-server ': executable file not found in $PATH
1. Manual Installation
Generate certificates and Signatures Section reference: Install the Go Language debugging tool DLV
Delve download to run the command:
$ go get github.com/derekparker/delve/cmd/dlv
Go get will compile and install DLV directly, and you will need to run the following command to sign DLV after the certificate is generated.
$ CERT=dlv-cert make install
2. Homebrew Installation
Run the command:
$ brew install go-delve/delve/delve
In theory, according to the above two methods can be normal debugging go program, but the reality is always like to face, the following is the author in accordance with the two methods of operation encountered some of the pits and found solutions.
Pits
- The following error occurred attempting to start debugging:
Could not launch Process:stub exited while waiting for connection:exit status 0
Process exiting with Code:1
Solution: Add the following parameters to the configuration file Launch.json (the principle is unclear):
"backend": "native"
- After I have manually generated the certificate and signed it, I always encounter the following error when debugging:
Could not launch process:could not fork/exec
The nature of manual and homebrew installation is actually the same, except that the homebrew automatically generates a certificate and signs the compiled DLV file during installation. The analysis can basically determine the issue of a manually generated certificate (there is no problem with the certificate yet)
- Then try to homebrew installation, or not smooth (heart tired), by adding the verbose parameter in the installation command to see what went wrong
$ brew Install Go-delve/delve/delve--verbose==> Installing delve from GO-DELVE/DELVE/USR/BIN/SANDBOX-EXEC-F/ PRIVATE/TMP/HOMEBREW20180830-36206-1AEUZHJ.SB nice/usr/local/homebrew/library/homebrew/vendor/portable-ruby/ 2.3.7/bin/ruby-w0-i/usr/local/homebrew/library/homebrew:/usr/local/homebrew/library/homebrew/cask/lib--/usr/ local/homebrew/library/homebrew/build.rb/usr/local/homebrew/library/taps/go-delve/homebrew-delve/formula/ DELVE.RB--verbose==> downloading Https://github.com/derekparker/delve/archive/v1.0.0.tar.gzAlready downloaded: /users/xiongrudy/library/caches/homebrew/delve-1.0.0.tar.gz==> Verifying delve-1.0.0.tar.gz Checksumtar XF/ Users/xiongrudy/library/caches/homebrew/delve-1.0.0.tar.gz-c/private/tmp/delve-20180830-36208-krq4cfsecurity: Seckeychainsearchcopynext:the specified item could not being found in the keychain.==> generating dlv-cert==> OpenSSL Req-new-newkey rsa:2048-x509-days 3650-nodes-config dlv-cert.cfg-extensions codesign_reqext -batch-out Dlv-cert.cer-keyout dlv-cert.keygenerating A 2048 bit RSA private key...........................+++ .... ..... +++writing new private key to ' dlv-cert.key '-----==> [SUDO] installing Dlv-cert as root==> SUDO S, ..... Ecurity add-trusted-cert-d-R trustroot-k/library/keychains/system.keychain dlv-cert.cerfailed to Execute:sudo
Failed to Execute:sudo, okay, that's the problem with the permissions (probably the problem with the system)
But homebrew installation does not let the user input password Ah, then go to manually execute the installation script,
Can see delve-1.0.0.tar.gz This package has been downloaded, and then into the homebrew directory, execute the following command
$ cd $HOME/Library/Caches/Homebrew$ tar xf delve-*.gz$ cd delve-1.0.0 (我的是 delve-1.0.0 )$ sh scripts/gencert.sh
Perform the installation again:
$ brew Install Go-delve/delve/delve--verbose==> Installing delve from GO-DELVE/DELVE/USR/BIN/SANDBOX-EXEC-F/ PRIVATE/TMP/HOMEBREW20180830-37438-HFL3M9.SB nice/usr/local/homebrew/library/homebrew/vendor/portable-ruby/ 2.3.7/bin/ruby-w0-i/usr/local/homebrew/library/homebrew:/usr/local/homebrew/library/homebrew/cask/lib--/usr/ local/homebrew/library/homebrew/build.rb/usr/local/homebrew/library/taps/go-delve/homebrew-delve/formula/ DELVE.RB--verbose==> downloading Https://github.com/derekparker/delve/archive/v1.0.0.tar.gzAlready downloaded: /users/xiongrudy/library/caches/homebrew/delve-1.0.0.tar.gz==> Verifying delve-1.0.0.tar.gz Checksumtar XF/ Users/xiongrudy/library/caches/homebrew/delve-1.0.0.tar.gz-c/private/tmp/delve-20180830-37440-1fuuoa5==> Dlv-cert is already installed, no need to create it==> make build Build_sha=v1.0.0go build-ldflags= "-s-x Main. build=v1.0.0 "Github.com/derekparker/delve/cmd/dlvcodesign-s" Dlv-cert "./dlv==> Cleaning==> FinishiNg Upln-s. /CELLAR/DELVE/1.0.0/BIN/DLV DLV
No problem. (You can see that the certificate is already installed and you don't need to create it again)
In fact, if you use this certificate and the manual installation of the DLV signature is also possible (the author pro-Test available, it appears that the manual generated certificate is indeed problematic, although I did not study the problem where)
Start debugging again, done, such as:
Screen shot 2018-08-30 11.23.33.png