国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Golang調(diào)試工具Delve安裝及使用

這篇具有很好參考價(jià)值的文章主要介紹了Golang調(diào)試工具Delve安裝及使用。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、安裝
1.拉取最新 delve 項(xiàng)目代碼到本地,編譯安裝。

# cd $GOPATH/src/
# git clone https://github.com/go-delve/delve.git
# cd delve/cmd/dlv/
# go build
# go install

2.添加$GOPATH/bin到環(huán)境變量,執(zhí)行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 with a terminal client.
  core        Examine a core dump.
  dap         Starts a headless 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 via JSON-RPC or DAP.
      --allow-non-terminal-interactive   Allows interactive sessions of Delve that don't have a terminal as stdin, stdout and stderr
      --api-version int                  Selects JSON-RPC 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. For example: --build-flags="-tags=integration -mod=vendor -cover -v"
      --check-go-version                 Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve. (default true)
      --disable-aslr                     Disables address space randomization
      --headless                         Run debug server only, in headless mode. Server will accept both JSON-RPC or DAP client connections.
  -h, --help                             help for dlv
      --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)
  -r, --redirect stringArray             Specifies redirect rules for target process (see 'dlv help redirect')
      --wd string                        Working directory for running the program.

Additional help topics:
  dlv backend  Help about the --backend flag.
  dlv log      Help about logging flags.
  dlv redirect Help about file redirection.

Use "dlv [command] --help" for more information about a command.

二、使用 Delve 調(diào)試程序
1.查看 Delve 支持命令:dlvdlv --help,如下:

Available Commands:
  attach      Attach to running process and begin debugging.
  connect     Connect to a headless debug server.
  core        Examine a core dump.
  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.

2.查詢(xún)單個(gè)命令詳情,dlv [command] --help,如:dlv debug --help

3.調(diào)試程序
手動(dòng)創(chuàng)建一個(gè)helloworld項(xiàng)目,main.go里面打印一些信息,如:

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

執(zhí)行debug調(diào)試:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-677429.html

# cd helloword/
# go mod init
# dlv debug main.go

到了這里,關(guān)于Golang調(diào)試工具Delve安裝及使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Go 工具鏈詳解(四): Golang環(huán)境變量設(shè)置和查看工具 go env

    go env 是 Go 工具鏈中的一個(gè)命令,用于設(shè)置和查看當(dāng)前 Golang 環(huán)境的相關(guān)信息,對(duì)于理解、編譯和運(yùn)行 Golang 程序非常有用。 go 提供的命令及 go 程序的編譯運(yùn)行都會(huì)使用到環(huán)境變量,如果未設(shè)置對(duì)應(yīng)的環(huán)境變量,go 則會(huì)使用其默認(rèn)設(shè)置。默認(rèn)情況下,env 以 shell 腳本(在Windo

    2024年02月16日
    瀏覽(58)
  • 【GoLang】MAC安裝Go語(yǔ)言環(huán)境

    【GoLang】MAC安裝Go語(yǔ)言環(huán)境

    小試牛刀 首先安裝VScode軟件 或者pycharm mac安裝brew軟件? brew install go 報(bào)了一個(gè)錯(cuò)誤 不提供這個(gè)支持? 重新brew install go 之后又重新brew reinstall go 使用go version 可以看到go 的版本 使用go env ?可以看到go安裝后的配置 配置一個(gè)環(huán)境變量 vim ~/.zshrc, ?

    2024年02月15日
    瀏覽(28)
  • 【Golang中的Go Module使用】

    Golang中的Go Module是一個(gè)用于包管理和版本控制的工具。在本文中,我們將深入探討Go Module的相關(guān)知識(shí),包括其定義、使用方法以及一些常見(jiàn)的應(yīng)用場(chǎng)景。 Go Module是Golang中的包管理和版本控制工具,它的發(fā)展歷程、用法、意義以及相關(guān)指令都對(duì)于Golang開(kāi)發(fā)者來(lái)說(shuō)非常重要。在本

    2024年02月16日
    瀏覽(18)
  • 【Golang】Golang進(jìn)階系列教程--為什么 Go 語(yǔ)言 struct 要使用 tags

    【Golang】Golang進(jìn)階系列教程--為什么 Go 語(yǔ)言 struct 要使用 tags

    在 Go 語(yǔ)言中,struct 是一種常見(jiàn)的數(shù)據(jù)類(lèi)型,它可以用來(lái)表示復(fù)雜的數(shù)據(jù)結(jié)構(gòu)。在 struct 中,我們可以定義多個(gè)字段,每個(gè)字段可以有不同的類(lèi)型和名稱(chēng)。 除了這些基本信息之外,Go 還提供了 struct tags,它可以用來(lái)指定 struct 中每個(gè)字段的元信息。 在本文中,我們將探討為什

    2024年02月15日
    瀏覽(40)
  • 【GoLang】哪些大公司正在使用Go語(yǔ)言

    【GoLang】哪些大公司正在使用Go語(yǔ)言

    前言: 隨著計(jì)算機(jī)科學(xué)和軟件開(kāi)發(fā)的快速發(fā)展,編程語(yǔ)言的選擇變得愈加關(guān)鍵。 在這個(gè)多元化的編程語(yǔ)境中,Go語(yǔ)言(簡(jiǎn)稱(chēng)Golang)以其簡(jiǎn)潔、高效、并發(fā)處理能力等特性逐漸受到業(yè)界關(guān)注。 越來(lái)越多的大型科技公司紛紛采用Go語(yǔ)言作為其軟件開(kāi)發(fā)的首選語(yǔ)言,這種趨勢(shì)反映了

    2024年02月04日
    瀏覽(18)
  • 使用 Go (Golang) 使用 OpenCV 繪制對(duì)象 GoCV

    使用 Go (Golang) 使用 OpenCV 繪制對(duì)象 GoCV

    本文將向你展示如何使用 OpenCV 使用 Go 編程語(yǔ)言 (Golang) 和 GoCV 包繪制直線、正方形、圓形和橢圓形對(duì)象。 OpenCV 是一個(gè)主要用于實(shí)時(shí)計(jì)算機(jī)視覺(jué)的編程函數(shù)庫(kù)。最初由 Intel 開(kāi)發(fā),然后由 Willow Garage 和 Itseez 提供支持。這個(gè)庫(kù)是跨平臺(tái)的,可以在開(kāi)源 Apache 2 許可下免費(fèi)使用。

    2024年02月07日
    瀏覽(24)
  • 一、安裝GoLang環(huán)境和開(kāi)發(fā)工具

    一、安裝GoLang環(huán)境和開(kāi)發(fā)工具

    GoLang中國(guó)鏡像站 下載后對(duì)應(yīng)的環(huán)境包以后,一路下一步就好了,安裝路徑的話,盡量就安裝到默認(rèn)的文件目錄下。 右擊此電腦–屬性–高級(jí)系統(tǒng)設(shè)置–環(huán)境變量,打開(kāi)環(huán)境變量設(shè)置窗口。 將當(dāng)前環(huán)境設(shè)置到Path環(huán)境變量下 由于GoLang下載依賴(lài)包是從國(guó)外進(jìn)行下載的,所以會(huì)特

    2024年02月10日
    瀏覽(89)
  • golang IDE 使用 go-1.7 無(wú)法識(shí)別 goroot問(wèn)題

    golang IDE 使用 go-1.7 無(wú)法識(shí)別 goroot問(wèn)題

    當(dāng)前使用了 golang IDE 要設(shè)定 go-1.17 版本作為默認(rèn) GOROOT 系統(tǒng)環(huán)境變量已經(jīng)定義好 打開(kāi)了 ide 會(huì)出現(xiàn)下面問(wèn)題,選擇 1.17 后會(huì)出現(xiàn)下面報(bào)錯(cuò) The selected directory is not a valid horne for GO SDK 修改 $GOROOT 下文件增加一個(gè)變量 再次在 IDC 選擇 GOROOT 就可以找到 go 1.17.2 版本 選擇后,需要關(guān)閉

    2024年02月16日
    瀏覽(48)
  • golang利用go mod巧妙替換使用本地項(xiàng)目的包

    golang利用go mod巧妙替換使用本地項(xiàng)目的包

    ??拉了兩個(gè)項(xiàng)目下來(lái),其中一個(gè)項(xiàng)目依賴(lài)另一個(gè)項(xiàng)目,因?yàn)楦膭?dòng)了被依賴(lài)的項(xiàng)目,想重新導(dǎo)入測(cè)試一下。 ??go.mod文件的require中想要被代替的包名在replace中進(jìn)行一個(gè)替換,注意:用來(lái)替換的需要用絕對(duì)路徑,一開(kāi)始我用~/Documents/xboot/xboot/tools/reflect沒(méi)有效果。 ??這樣原

    2024年02月15日
    瀏覽(29)
  • CentOS 9 x64 使用 Nginx、Supervisor 部署 Go/Golang 服務(wù)

    在 CentOS 9 x64 系統(tǒng)上,可以通過(guò)以下步驟來(lái)部署 Golang 服務(wù)。 安裝以下軟件包: Golang:Golang 編程語(yǔ)言 Nginx:Web 服務(wù)器 Supervisor:進(jìn)程管理工具 Git:版本控制工具 EPEL:擴(kuò)展軟件包 可以通過(guò)以下命令來(lái)安裝: 為 Git 生成 SSH 密鑰,以便于進(jìn)行代碼管理??梢酝ㄟ^(guò)以下命令來(lái)生成

    2024年02月12日
    瀏覽(43)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包