vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

logpoints not printing out entire object

Open akibrhast opened this issue 3 years ago • 2 comments

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.

    • go1.19 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • v0.9.4
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • v1.71.0
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.35.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/akibmohaimenurrahman/Library/Caches/go-build" GOENV="/Users/akibmohaimenurrahman/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/akibmohaimenurrahman/go/pkg/mod" GONOPROXY="github.com/Tritura/" GONOSUMDB="github.com/Tritura/" GOOS="darwin" GOPATH="/Users/akibmohaimenurrahman/go" GOPRIVATE="github.com/Tritura/*" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/homebrew/opt/go/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/96/n6gn80q57hq7052j59gtgwyc0000gn/T/go-build2670980064=/tmp/go-build -gno-record-gcc-switches -fno-common"

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.testFlags": [
        "-count=1",
    
    ],
    "go.lintTool": "golangci-lint",
    "go.delveConfig": {
        "apiVersion": 2,
    "debugAdapter": "dlv-dap",
    "logOutput": "dap",
    "showLog": true,
    },
    "gopls": {
    "ui.semanticTokens": true
    },

Describe the bug

A clear and concise description of what the bug.

  • When using logpoints to log variables that structs the print out cuts away halfway through
# got:\n {tag1)
> [Go 126]: Got:\n *github.com/Tritura/quarterjack-go-toolkit/neo4j/annotation.Tag {LinkAnnotation: github.com/Tritura/quarterjack-go-toolkit/neo4j/annotation.LinkAnnotation {Base: (*"github.com/Tritura/quarterjack-go-toolkit/neo4j/annotation.Base")(0x140008385b0), LinkType:...

A clear and concise description of what you expected to happen.

  • When using logpoints to log variables that are structs I want to see the entire object
# log.Debug().Msgf("Expected:\n %+v", tag1)
tag_test.go:147 > Expected:
 &{LinkAnnotation:{Base:{Id:b7b2ffa2-2419-451d-934f-7860dfb151fb StateId:b8c2ed99-bb07-495d-b83f-564fa9831a47 Type:Link CreatedBy:1f2f11d8-00c0-4076-ba5a-df4e81db7efb ModifiedBy:1f2f11d8-00c0-4076-ba5a-df4e81db7efb CreatedOn:2022-09-08 20:50:45.852 +0000 UTC ModifiedOn:2022-09-08 20:50:45.852 +0000 UTC Archived:false Properties:map[] ParentId:8c034985-1690-4b06-a8dd-f44d6a13ee48 Label:Test Tag Label} LinkType:Tag} Color:red}

Steps to reproduce the behavior:

The struct setup I have for example

type Base struct {
	Id         string                 `json:"id" mapstructure:"id,omitempty"`
	StateId    string                 `json:"stateId" mapstructure:"stateId,omitempty"`
	Type       string                 `json:"type" mapstructure:"type"`
	CreatedBy  string                 `json:"createdBy" mapstructure:"createdBy,omitempty"`
	ModifiedBy string                 `json:"modifiedBy" mapstructure:"modifiedBy,omitempty"`
	CreatedOn  time.Time              `json:"createdOn" mapstructure:"createdOn,omitempty"`
	ModifiedOn time.Time              `json:"modifiedOn" mapstructure:"modifiedOn,omitempty"`
	Archived   bool                   `json:"archived" mapstructure:"archived"`
	Properties map[string]interface{} `json:"properties" mapstructure:"properties"`
	ParentId   string                 `json:"parentId" mapstructure:"parentId"`
	Label      string                 `json:"label" mapstructure:"label"`
	// Labels     []string               `json:"labels" mapstructure:"labels"`
}

type LinkAnnotation struct {
	Base
	LinkType string `json:"linkType" mapstructure:"linkType"`
}

type Tag struct {
	LinkAnnotation
	Color string `json:"color" mapstructure:"string"`
}
  1. Create a large nested struct at least 3 layers deep
  2. Try to log it using the logpoint option on vscode
  3. See issue of not printing out the whole thing

Screenshots or recordings

image image

akibrhast avatar Sep 08 '22 20:09 akibrhast

I believe we've seen similar limitations in the past with other aspects of the debugger, but I'm surprised it affects log points.

CC @suzmue

findleyr avatar Sep 20 '22 12:09 findleyr

The string value gets truncated here: https://github.com/go-delve/delve/blob/9bcccf81ed7c93a6f1ea4bfc0d905178e6db8e81/service/dap/server.go#L2596.

This truncating should probably be skipped for log points.

suzmue avatar Sep 20 '22 18:09 suzmue