Skip to content

debug: variable watcher escapes json inside []byte #1821

Open
@gudvinr

Description

@gudvinr

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.17.1 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.7.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.60.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.28.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • gopkgs: ~/tools/go/path/bin/gopkgs: go1.17.1
      go-outline: ~/tools/go/path/bin/go-outline: go1.17.1
      gotests: ~/tools/go/path/bin/gotests: go1.17.1
      gomodifytags: ~/tools/go/path/bin/gomodifytags: go1.17.1
      impl: ~/tools/go/path/bin/impl: go1.17.1
      goplay: not installed
      dlv: ~/tools/go/path/bin/dlv: go1.17.1
      dlv-dap: ~/tools/go/path/bin/dlv-dap: go1.17.1

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.toolsManagement.autoUpdate": true,
    "go.vetOnSave": "workspace",
    "go.lintOnSave": "workspace",
    "go.toolsGopath": "~/tools/go/path",
    "gopls": {
        "build.experimentalWorkspaceModule": false,
        "ui.documentation.linksInHover": false,
        "usePlaceholders": false,
        "analyses": {
            "composites": false,
            "shadow": true,
            "ST1000": false,
            "ST1003": false
        },
        "ui.diagnostic.staticcheck": true
    }

Describe the bug

Variable watcher in debug view applies JSON escaping rules to string() if underlying type of variable []byte.

As you can see on screenshot, byte view shows 123 34 116 34 58 110 117 108 108 44 which is the representation of {"t":null, in ASCII/UTF-8.
But string() showing {\"t\":null, and it is incorrect representation of characters in input byte array.

Steps to reproduce the behavior:

  1. Place breakpoint where you can see []byte variable filled with valid JSON
  2. Go to Debug View panel
  3. Start debug session
  4. Wait for breakpoint to trigger

Screenshots or recordings

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebugIssues related to the debugging functionality of the extension.FeatureRequestdebug/variablesissues related to variables inspection/presentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions