引言

自己最近在玩Go,在开发一些项目的时候需要调试,由于之前都是在GoLand上写的,但是这个IDE启动太慢并且不轻便。并且自己之前很多项目都是在Vscode中编写的,所以特意想在Vscode中配置Go的开发环境和调试环境,由于在安装的过程中遇到了不少的问题,希望在此给自己留一个笔记,以便未来不再犯类似的错误

dlv的安装

dlv相关网址

在这里给出dlv的下载地址dlv github Link, 在这个网站上有对这个工具的详细介绍,并且有着对应的文档可以参考。

其中dlv的安装可以分成Linux、MacOS、Windows三个方向,自己用的是Windows,所以在这给出Windows下安装的方法,这里是Windows安装的方法Windows 安装dlv方法

dlv的安装步骤

安装dlv之前确认自己已经安装好了GoLang并且配置好了GOROOTGOPATH两个环境变量

  1. 打开cmd窗口输入命令go get github.com/derekparker/delve/cmd/dlv,等待几分钟,当下载完成之后可以切换到目录里GOPATH查看;

  2. 在cmd窗口种输入命令cd %GOPATH%,进入对应的目录文件夹里面

  3. 在src目录里找到dlv所在路径并且切换过去,最终进入 _scripts这个目录里面,开始编译安装

  4. 按顺序分别执行以下命令:

    go run make.go check-cert
    go run make.go build
    go run make.go install
  5. 执行完成之后,在cmd窗口中输入dlv后你会得到以下信息,说明dlv安装成功

Delve is a source level debugger for Go programs.

Delve enables you to interact with your program by controlling the execution of the process,
evaluating variables, and providing information of thread / goroutine state, CPU register state and more. The goal of this tool is to provide a simple yet powerful interface for debugging Go programs. Pass flags to the program you are debugging using `--`, for example: `dlv exec ./hello -- server --config conf/config.toml` Usage:
dlv [command] Available Commands:
attach Attach to running process and begin debugging.
connect Connect to a headless debug server.
core Examine a core dump.
dap [EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP).
debug Compile and begin debugging main package in current directory, or the package specified.
exec Execute a precompiled binary, and begin a debug session.
help Help about any command
run Deprecated command. Use 'debug' instead.
test Compile test binary and begin debugging program.
trace Compile and begin tracing program.
version Prints version. Flags:
--accept-multiclient Allows a headless server to accept multiple client connections.
--api-version int Selects API version when headless. New clients should use v2. Can be reset via RPCServer.SetApiVersion. See Documentation/api/json-rpc/README.md. (default 1)
--backend string Backend selection (see 'dlv help backend'). (default "default")
--build-flags string Build flags, to be passed to the compiler.
--check-go-version Checks that the version of Go in use is compatible with Delve. (default true)
--headless Run debug server only, in headless mode.
--init string Init file, executed by the terminal client.
-l, --listen string Debugging server listen address. (default "127.0.0.1:0")
--log Enable debugging server logging.
--log-dest string Writes logs to the specified file or file descriptor (see 'dlv help log').
--log-output string Comma separated list of components that should produce debug output (see 'dlv help log')
--only-same-user Only connections from the same user that started this instance of Delve are allowed to connect. (default true)
--wd string Working directory for running the program. (default ".") Additional help topics:
dlv backend Help about the --backend flag.
dlv log Help about logging flags. Use "dlv [command] --help" for more information about a command.

参考文档

  1. https://stackoverflow.com/questions/39058823/how-to-use-delve-debugger-in-visual-studio-code
  2. https://github.com/derekparker/delve/
  3. https://github.com/golang/vscode-go
  4. https://juejin.im/entry/5e69a2276fb9a07cd11db163

最新文章

  1. nginx-(/usr/local/nginx)配置编译
  2. SQL SERVER增加、删除、更改表中的字段名 (详询请加qq:2085920154)
  3. Hibernate查询
  4. js 随机星星 document.createElement(); setAttribute()
  5. jquery中each()函数
  6. jboss服务器配置多实例
  7. polya定理小结
  8. ML神器:sklearn的快速使用
  9. [国嵌笔记][008-009][远程登录Linux]
  10. freemarker之include指令
  11. Spark入门(1-1)什么是spark,spark和hadoop
  12. Ftp修改为主被动模式命令
  13. 为什么使用Nosql:Nosql和SQL的区别
  14. {python之IO多路复用} IO模型介绍 阻塞IO(blocking IO) 非阻塞IO(non-blocking IO) 多路复用IO(IO multiplexing) 异步IO(Asynchronous I/O) IO模型比较分析 selectors模块
  15. Python 类对象去重
  16. C语言 · 复数求和
  17. 如何通过SSH及其Client 批量分发文件和执行管理命令
  18. Dokcer制作nginx镜像,提交镜像至仓库
  19. Java中HTTP通信
  20. PostgreSQL逻辑复制槽

热门文章

  1. IDEA环境Spring Boot 2.3整合Activiti 6.0,启动项目初始化表并创建核心服务
  2. 关于wifi营销的看过来
  3. uni-app动态修改顶部导航栏标题
  4. JPA 中 find() 和 getReference() 的区别
  5. Remap 后的 USART1 不能发送数据
  6. @codeforces - 607E@ Cross Sum
  7. cheerio html方法中文被编码问题
  8. PowerBuilder中DW如何手动触发事件
  9. cb25a_c++_函数对象简介
  10. EPLAN文本输入怎么转行,路径功能文本换行方法