最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

VSCode Golang dlv調(diào)試數(shù)據(jù)截斷問題及處理方法

 更新時間:2020年06月24日 14:12:51   作者:FanZheng''s Debug Blog  
這篇文章主要介紹了VSCode Golang dlv調(diào)試數(shù)據(jù)截斷問題,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

使用VSCode對Golang程序進(jìn)行調(diào)試時會遇到數(shù)據(jù)截斷問題,string只顯示前64個字符,array只顯示前64個數(shù)據(jù)。經(jīng)查dlv是支持以參數(shù)方式來控制的。

發(fā)現(xiàn)VSCode的Golang插件里面有個叫做go.delveConfig的配置,是可以設(shè)置dlv參數(shù)的。分享一下我的整個Golang配置:

"go.buildOnSave": "off",
  "go.formatTool": "goimports",
  "go.lintTool": "golangci-lint", //go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
  "go.autocompleteUnimportedPackages": true,
  "go.gotoSymbol.includeImports": true,
  "go.useLanguageServer": true,
  "go.delveConfig": {
    "dlvLoadConfig": {
      "followPointers": true,
      "maxVariableRecurse": 3,
      "maxStringLen": 1024,
      "maxArrayValues": 1024,
      "maxStructFields": -1
    },
  },
  "[go]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },

需要改的主要是maxStringLen、maxArrayValues、maxVariableRecurse這三個字段。

參考:https://stackoverflow.com/questions/52416263/how-do-i-print-the-full-value-of-a-string-variable-in-delve

ps:下面看下Golang dlv 工具debug 調(diào)試注意項

總結(jié)一下關(guān)于Go 的調(diào)試工具dlv:https://github.com/derekparker/delve 的使用注意項。

安裝:

go get -u github.com/go-delve/delve/cmd/dlv

配置:

以Centos為例

export GOROOT=/usr/lib/golang
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

使用

以某go服務(wù)為例:

  • dlv debug xxx.go 指定需要debug的文件
  • 進(jìn)入dlv交互式窗口后,b <filename>:<line> 指定斷點
  • r arg 指定運行參數(shù)
  • n 執(zhí)行一行
  • c 運行至斷點或程序結(jié)束
dlv debug /home/xxx/server.go
(dlv) b /home/xxx/server.go:258
(dlv) r 1
(dlv) n
(dlv) c

注意: b <filename>:<line> 指定斷點時,若該行號對應(yīng)的代碼內(nèi)容為無具體語義的代碼(括號、注釋等),則會報錯:

Command failed: could not find /home/xxx/server.go:258

此時可用list 命令先查看上下文代碼,避免將無具體語義的代碼設(shè)為斷點。

命令集

The following commands are available:
    args ------------------------ Print function arguments.
    break (alias: b) ------------ Sets a breakpoint.
    breakpoints (alias: bp) ----- Print out info for active breakpoints.
    call ------------------------ Resumes process, injecting a function call (EXPERIMENTAL!!!)
    clear ----------------------- Deletes breakpoint.
    clearall -------------------- Deletes multiple breakpoints.
    condition (alias: cond) ----- Set breakpoint condition.
    config ---------------------- Changes configuration parameters.
    continue (alias: c) --------- Run until breakpoint or program termination.
    deferred -------------------- Executes command in the context of a deferred call.
    disassemble (alias: disass) - Disassembler.
    down ------------------------ Move the current frame down.
    edit (alias: ed) ------------ Open where you are in $DELVE_EDITOR or $EDITOR
    exit (alias: quit | q) ------ Exit the debugger.
    frame ----------------------- Set the current frame, or execute command on a different frame.
    funcs ----------------------- Print list of functions.
    goroutine ------------------- Shows or changes current goroutine
    goroutines ------------------ List program goroutines.
    help (alias: h) ------------- Prints the help message.
    list (alias: ls | l) -------- Show source code.
    locals ---------------------- Print local variables.
    next (alias: n) ------------- Step over to next source line.
    on -------------------------- Executes a command when a breakpoint is hit.
    print (alias: p) ------------ Evaluate an expression.
    regs ------------------------ Print contents of CPU registers.
    restart (alias: r) ---------- Restart process.
    set ------------------------- Changes the value of a variable.
    source ---------------------- Executes a file containing a list of delve commands
    sources --------------------- Print list of source files.
    stack (alias: bt) ----------- Print stack trace.
    step (alias: s) ------------- Single step through program.
    step-instruction (alias: si)  Single step a single cpu instruction.
    stepout --------------------- Step out of the current function.
    thread (alias: tr) ---------- Switch to the specified thread.
    threads --------------------- Print out info for every traced thread.
    trace (alias: t) ------------ Set tracepoint.
    types ----------------------- Print list of types
    up -------------------------- Move the current frame up.
    vars ------------------------ Print package variables.
    whatis ---------------------- Prints type of an expression.

總結(jié)

到此這篇關(guān)于VSCode Golang dlv調(diào)試數(shù)據(jù)截斷問題及處理方法的文章就介紹到這了,更多相關(guān)VSCode Golang dlv調(diào)試數(shù)據(jù)截斷內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解如何修改Go結(jié)構(gòu)體的私有字段

    詳解如何修改Go結(jié)構(gòu)體的私有字段

    在 Go 語言中,結(jié)構(gòu)體字段的訪問權(quán)限是由字段名的首字母決定的:首字母大寫表示公共字段(public),首字母小寫表示私有字段(private),本文給大家介紹了如何修改Go結(jié)構(gòu)體的私有字段,需要的朋友可以參考下
    2025-01-01
  • Go實現(xiàn)set類型的示例代碼

    Go實現(xiàn)set類型的示例代碼

    本文主要介紹了Go實現(xiàn)set類型的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • 詳解Go語言中如何高效地處理集合

    詳解Go語言中如何高效地處理集合

    在?Go?語言中,雖然沒有像?Java?或?Python?那樣的傳統(tǒng)集合框架,但也可以非常高效地處理集合操作,下面小編就來和大家講講具體處理方法吧
    2025-01-01
  • golang去除多余的空格與換行符示例代碼

    golang去除多余的空格與換行符示例代碼

    Golang是一種強大的編程語言,提供了豐富的字符串處理功能,這篇文章主要給大家介紹了關(guān)于golang去除多余的空格與換行符的相關(guān)資料,需要的朋友可以參考下
    2023-10-10
  • VSCode1.4 搭建Golang的開發(fā)調(diào)試環(huán)境(遇到很多問題)

    VSCode1.4 搭建Golang的開發(fā)調(diào)試環(huán)境(遇到很多問題)

    這篇文章主要介紹了VSCode1.4 搭建Golang的開發(fā)調(diào)試環(huán)境(遇到很多問題),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-04-04
  • go語言實現(xiàn)LRU緩存的示例代碼

    go語言實現(xiàn)LRU緩存的示例代碼

    LRU是一種常見的緩存淘汰策略,用于管理緩存中的數(shù)據(jù),本文主要介紹了go語言實現(xiàn)LRU緩存的示例代碼,具有一定的參考價值,感興趣的可以了解一下
    2024-02-02
  • go語言實現(xiàn)一個簡單的http客戶端抓取遠(yuǎn)程url的方法

    go語言實現(xiàn)一個簡單的http客戶端抓取遠(yuǎn)程url的方法

    這篇文章主要介紹了go語言實現(xiàn)一個簡單的http客戶端抓取遠(yuǎn)程url的方法,實例分析了Go語言http操作技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-03-03
  • Golang生成Excel文檔的方法步驟

    Golang生成Excel文檔的方法步驟

    生成Excel是一個很常見的需求,本文將介紹如何使用Go的 Excelize庫去生成Excel文檔,以及一些具體場景下的代碼實現(xiàn),感興趣的可以參考一下
    2021-06-06
  • GoFrame?gmap遍歷hashmap?listmap?treemap使用技巧

    GoFrame?gmap遍歷hashmap?listmap?treemap使用技巧

    這篇文章主要為大家介紹了GoFrame?gmap遍歷hashmap?listmap?treemap使用技巧的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Go log庫的使用示例詳解

    Go log庫的使用示例詳解

    Go語言內(nèi)置的log庫提供了基本的日志記錄功能,支持日志的格式化輸出、設(shè)置日志前綴、配置輸出位置等,可以通過標(biāo)準(zhǔn)logger或創(chuàng)建新的Logger對象來使用,log庫簡單易用,但功能有限,可能需要配合第三方日志庫如logrus、zap等來滿足復(fù)雜需求
    2024-09-09

最新評論

邛崃市| 沂源县| 南城县| 称多县| 汉源县| 拉孜县| 宁城县| 根河市| 合水县| 茶陵县| 申扎县| 安陆市| 三台县| 长泰县| 彰武县| 富蕴县| 蕉岭县| 罗甸县| 赤城县| 宣威市| 东阳市| 霍城县| 东方市| 营口市| 黄平县| 乌拉特前旗| 迁西县| 沅陵县| 赫章县| 二连浩特市| 县级市| 岳阳市| 安徽省| 元谋县| 静乐县| 峡江县| 永仁县| 大港区| 临沭县| 页游| 民权县|