校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > VSCode Golang dlv調試數據截斷問題及處理方法

VSCode Golang dlv調試數據截斷問題及處理方法

熱門標簽:賺地圖標注的錢犯法嗎 澳門防封電銷卡 廣東語音外呼系統供應商 濮陽自動外呼系統代理 烏魯木齊人工電銷機器人系統 福州鐵通自動外呼系統 智能電銷機器人營銷 地圖標注測試 長沙ai機器人電銷

使用VSCode對Golang程序進行調試時會遇到數據截斷問題,string只顯示前64個字符,array只顯示前64個數據。經查dlv是支持以參數方式來控制的。

發現VSCode的Golang插件里面有個叫做go.delveConfig的配置,是可以設置dlv參數的。分享一下我的整個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
    }
  },

需要改的主要是maxStringLenmaxArrayValuesmaxVariableRecurse這三個字段。

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

ps:下面看下Golang dlv 工具debug 調試注意項

總結一下關于Go 的調試工具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服務為例:

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

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

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

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

命令集

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.

總結

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

您可能感興趣的文章:
  • VSCode1.4 搭建Golang的開發調試環境(遇到很多問題)
  • 解決vscode中golang插件依賴安裝失敗問題
  • 手把手教你vscode配置golang開發環境的步驟

標簽:太原 阿克蘇 廣西 慶陽 調研邀請 貴陽 西雙版納 德州

巨人網絡通訊聲明:本文標題《VSCode Golang dlv調試數據截斷問題及處理方法》,本文關鍵詞  VSCode,Golang,dlv,調試,數據,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《VSCode Golang dlv調試數據截斷問題及處理方法》相關的同類信息!
  • 本頁收集關于VSCode Golang dlv調試數據截斷問題及處理方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 英山县| 正宁县| 黎城县| 马尔康县| 伊春市| 芷江| 盐池县| 浦东新区| 定安县| 菏泽市| 五河县| 云浮市| 黄山市| 鹤岗市| 盐津县| 绿春县| 济宁市| 綦江县| 兰坪| 分宜县| 吉木萨尔县| 南充市| 兴业县| 麻栗坡县| 尤溪县| 麻阳| 福海县| 开封县| 贵溪市| 密云县| 建宁县| 鄂托克前旗| 阜新市| 长治县| 华亭县| 东明县| 宝坻区| 灵川县| 托克逊县| 永顺县| 翼城县|