golang dlv 安装

一.  dlv调试器安装:
1. Clone the git repository and build:
$ git clone https://github.com/go-delve/delve
$ cd delve
$ go install github.com/go-delve/delve/cmd/dlv

2. Alternatively, on Go version 1.16 or later:
# Install the latest release:
$ go install github.com/go-delve/delve/cmd/dlv@latest

3. Install at tree head:
$ go install github.com/go-delve/delve/cmd/dlv@master

4. Install at a specific version or pseudo-version:
$ go install github.com/go-delve/delve/cmd/dlv@v1.7.0    go.1.11
$ go install github.com/go-delve/delve/cmd/dlv@v1.7.3    go.1.16
$ go install github.com/go-delve/delve/cmd/dlv@v1.7.4-0.20211208103735-2f13672765fe

 

二. dlv版本和golang版本一致处理
这里要提go mod好处了,go.mod文件管理版本相关,包括依赖包版本

1. 本地环境:
  GOPATH: D:\gopath
  go version: go version go1.13.3 windows/amd64

2. cd D:\gopath\pkg\mod\github.com\go-delve\delve@v1.7.0

3. cat go.mod, 内容如下:

module github.com/go-delve/delve

go 1.11

require (
    github.com/cosiner/argv v0.1.0
    github.com/cpuguy83/go-md2man v1.0.10 // indirect
    github.com/creack/pty v1.1.9
    github.com/google/go-dap v0.5.0
    github.com/hashicorp/golang-lru v0.5.4
    github.com/inconshreveable/mousetrap v1.0.0 // indirect
    github.com/mattn/go-colorable v0.0.0-20170327083344-ded68f7a9561
    github.com/mattn/go-isatty v0.0.3
    github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b
    github.com/sirupsen/logrus v1.6.0
    github.com/spf13/cobra v0.0.0-20170417170307-b6cb39589372
    github.com/spf13/pflag v0.0.0-20170417173400-9e4c21054fa1 // indirect
    go.starlark.net v0.0.0-20200821142938-949cc6f4b097
    golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4
    golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae
    golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f
    gopkg.in/yaml.v2 v2.2.1
)

4. 如上,说明delve@v1.7.0版本至少需要go 1.11版本

posted @ 2022-02-14 20:45  小夜天  阅读(5669)  评论(0编辑  收藏  举报