In any language, debugger is very important for development. After wandering around the Go language community, I found that the Go official does not implement the debugger, and the community actually uses the way of Print debugging, which is very unscientific. Then, continue to looked, only to find a better solution, that is DLV (https://github.com/derekparker/delve).

Dlv, also known as Delve, is a source debugging tool for the Go language. It was developed by derekparker and originated on Github. When configuring the Go language development environment on the Mac, we often encounter problems such as unsuccessful Dlv calls, failure to start applications, failure to debug, etc. Most of the problems are related to the security mechanism of the Mac.

The Mac uses CoDesign to sign applications, and programs without a signature have some limitations, such as not being able to act as debuggers. Of course, you can install homebrew-compiled Dlv via Homebrew for convenience.

Since I use vscode heavily, my debugger is mainly for configuring vscode, which is not complicated but rather cumbersome.

{" version ":" 0.2.0, "" configurations: [{" name" : "Launch", "type" : "go", "request" : "Launch", "mode" : "Debug", "remotePath" : ""," port ": 2345," the host ":" 127.0.0.1 ", "the program" : "${fileDirname}", "env" : {}, "args" : [], "showLog": true } ] }Copy the code

Go:Rich Go Language Support for Visual Studio Code

Then in your project, install the DLV

go get -u github.com/derekparker/delve/cmd/dlvCopy the code

If you do not have GOPATH configured, the debugger will start with the following error message:

Failed to continue: “Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your “GOPATH/bin” or “PATH”.”

Since I’m using ZSH, I configure GOPATH in the.zshrc file

export GOPATH=”$HOME/go”

export PATH=”$HOME/go/bin:$PATH”

Xcode-select –install: xcode-select –install: xcode-select –install: xcode-select –install: xcode-select –install

could not launch process: EOF

The version of Command Line Tools installed is too high for DLV to support. Just delete it, download the old Command Line Tools from Apple’s website, and install it again.

Run $sudo rm – rf/Library/Developer/CommandLineTools, then go

https://developer.apple.com/download/more/ to download the Command Line Tools (macOS 10.13) for Xcode 9.2-4 Dec, 2017.

The whole debugging took me about three hours. In fact, it was very quick to solve one by one, mainly using Google and Github issues. After all, many developers have encountered the same problems.


Long press the QR code to follow the public account:

You can also follow my Sina Weibo and search i_ICepy. I am looking forward to communicating with you.