go tool trace 在chrome 80 出現空白頁面的解決辦法

go tool trace -http=localhost:8080 trace.pprof

打開chrome 瀏覽器點擊 View trace 出現空白頁面,按 F12 看控制檯報錯 HTML Imports is deprecated and has now been removed as of M80. See https://www.chromestatus.com/features/5144752345317376 and https://developers.google.com/web/updates/2019/07/web-components-time-to-upgrade for more details.
原因是 chrome80 廢棄了一些 js 接口
解決辦法分兩步。
一:到 chrome 上申請權限 token
二:go 的 trace 工具生成的頁面,添加這個 token


具體做法。

  1. 訪問 https://developers.chrome.com/origintrials/#/register_trial/2431943798780067841 然後登錄,必須登錄纔可以繼續操作
  2. web origin 處填寫 http://localhost:8001 端口只能是 8000 - 8003,支持 http 和 https。然後下面多選框全選,頁面訪問次數,根據情況選,用得多就選數字大的。點擊註冊。會得到一個token。複製token。
  3. 編輯{GOROOT}/src/cmd/trace/trace.go 文件,在文件中找到 templTrace 然後在 <head> 標籤的下一行添加 <meta http-equiv="origin-trial" content="你複製的token">
  4. 回到{GOROOT}/src目錄,執行 .\make.bat 。如果報錯,出現
    
    ERROR: Cannot find C:\Users\YOUR\Go1.4\bin\go.exe
    Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
    那說明你缺少go的工具鏈。如果沒有報錯直接去第7步
  5. 根據錯誤提示,需要在 C:\Users\YOUR\Go1.4 安裝工具鏈,現在去 https://golang.org/doc/install/source#bootstrapFromSource 找到 源文件下載地址 https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz 然後把壓縮文件裏面的go文件夾下的內容解壓到 C:\Users\YOUR\Go1.4。
  6. 進入 C:\Users\YOUR\Go1.4\src 執行 .\make.bat。最後出現提示
    
    Installed Go for windows/amd64 in C:\Users\YOUR\go1.4
    Installed commands in C:\Users\YOUR\go1.4\bin

    說明執行成功。 再回到{GOROOT}/src目錄,執行 .\make.bat

  7. 然後再執行 go tool trace -http=localhost:8001 trace.pprof 就可以了。http參數的值,必須是第2步填寫的值

發佈了18 篇原創文章 · 獲贊 42 · 訪問量 16萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章