hello world

          隨筆 - 2, 文章 - 63, 評論 - 0, 引用 - 0
          數據加載中……

          vscode調試go程序

          隨著互聯網時代的飛速發展,我們編碼使用的開發利器也在不斷更新換代,古話說工欲善其事必先利其器。對于Go語言程序的開發者而言,當下最火的IDE應該非微軟的Visual Studio Code莫屬,下面給出怎樣在vscode中調試go程序的過程,以mac本為示例。
          當前已經準備好go的待調試代碼,main.go的函數位置為:
          /Users/tingfeng/Workspace/go/src/github.com/nsharecome/caccount/main.go

          1、編輯launch.json文件

          {
              // 使用 IntelliSense 了解相關屬性。 
              
          // 懸停以查看現有屬性的描述。
              
          // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
              "version": "0.2.0",
              "configurations": [
                  {
                      "name": "debug",
                      "type": "go",
                      "request": "launch",
                      "mode": "debug",
                      "port": 8899,
                      "host": "127.0.0.1",
                      "program": "/Users/tingfeng/Workspace/go/src/github.com/nsharecome/caccount/main.go",
                      "env": {},
                      "args": [    ],
                      "output": "${workspaceRoot}/bin/debug_caccount",
                      "showLog": true
                  },
              ]
          }

          2、點擊運行,報錯如下:
          2021/02/07 16:51:52 /Users/tingfeng/Workspace/go/src/github.com/nsharecome/caccount/main.go/debugger.go:101: launching process with args: [/Users/tingfeng/Workspace/go/src/github.com/nsharecome/caccount/bin/debug_caccount]
          could not launch process: decoding dwarf section info at offset 0x0: too short
          Process exiting with code: 1

          錯誤原因如下:安裝delve

          解決方式:
          git clone https://github.com/go-delve/delve.git $GOPATH/src/github.com/go-delve/delve
          go get -u github.com/derekparker/delve/cmd/dl

          利用delve手動調試可以參考:Delve調試器



          posted on 2021-02-07 16:58 聽風 閱讀(884) 評論(0)  編輯  收藏 所屬分類: go


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 宾阳县| 娱乐| 定陶县| 阳曲县| 岢岚县| 巧家县| 繁峙县| 望城县| 盱眙县| 晋江市| 聊城市| 揭东县| 麻江县| 大理市| 陈巴尔虎旗| 大港区| 敦化市| 阜宁县| SHOW| 德令哈市| 仁布县| 丰顺县| 台前县| 长海县| 共和县| 荥经县| 永兴县| 黄骅市| 永福县| 高雄市| 莲花县| 攀枝花市| 永春县| 桂东县| 尼玛县| 清水县| 阳高县| 黄大仙区| 德令哈市| 中西区| 昭苏县|