Skip to content

Output of t.Log is not displayed while debugging #3780

Open
@martin-sucha

Description

@martin-sucha

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.24.4 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
	 ----------
golang.org/x/tools/gopls v0.18.1
    golang.org/x/tools/gopls@v0.18.1 h1:2xJBNzdImS5u/kV/ZzqDLSvlBSeZX+pWY9uKVP7Pask=
    github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20241210194714-1829a127f884 h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0=
    golang.org/x/mod@v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
    golang.org/x/sync@v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
    golang.org/x/telemetry@v0.0.0-20241220003058-cc96b6e0d3d9 h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw=
    golang.org/x/text@v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
    golang.org/x/tools@v0.30.1-0.20250221230316-5055f70f240c h1:Ja/5gV5a9Vvho3p2NC/T2TtxhHjrWS/2DvCKMvA0a+Y=
    golang.org/x/vuln@v1.1.3 h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw=
    honnef.co/go/tools@v0.5.1 h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
    mvdan.cc/gofumpt@v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.24.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

Running in Cursor:

Version: 1.0.0
VSCode Version: 1.96.2
Commit: 53b99ce608cba35127ae3a050c1738a959750860
Date: 2025-06-04T19:26:40.367Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Linux x64 6.14.9-300.fc42.x86_64

I also tried with vanilla VS code:

Version: 1.100.3
Commit: 258e40fedc6cb8edf399a463ce3a9d32e7e1f6f3
Date: 2025-06-02T13:30:54.273Z
Electron: 34.5.1
ElectronBuildId: 11369351
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Linux x64 6.14.9-300.fc42.x86_64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.46.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /home/martin/go
GOROOT: /usr/local/go
PATH: /usr/local/go/bin:/home/martin/.local/bin:/tmp/.mount_CursorDq5tA5/usr/bin/:/tmp/.mount_CursorDq5tA5/usr/sbin/:/tmp/.mount_CursorDq5tA5/usr/games/:/tmp/.mount_CursorDq5tA5/bin/:/tmp/.mount_CursorDq5tA5/sbin/:/home/martin/.local/bin:/usr/local/bin:/usr/bin:<REDACTED>:/home/martin/go/bin:<REDACTED>:/home/martin/go/bin:<REDACTED>
PATH (vscode launched with): /home/martin/.local/bin:/tmp/.mount_CursorDq5tA5/usr/bin/:/tmp/.mount_CursorDq5tA5/usr/sbin/:/tmp/.mount_CursorDq5tA5/usr/games/:/tmp/.mount_CursorDq5tA5/bin/:/tmp/.mount_CursorDq5tA5/sbin/:/home/martin/.local/bin:/usr/local/bin:/usr/bin:/usr/local/go/bin:<REDACTED>:/home/martin/go/bin:<REDACTED>

## Tools

	go:	/usr/local/go/bin/go: go version go1.24.4 linux/amd64

	gopls:	/home/martin/go/bin/gopls	(version: v0.18.1 built with go: go1.24.0)
	gotests:	not installed
	gomodifytags:	not installed
	impl:	/home/martin/go/bin/impl	(version: v1.4.0 built with go: go1.24.3)
	goplay:	not installed
	dlv:	/home/martin/go/bin/dlv	(version: v1.24.1 built with go: go1.24.2)
	staticcheck:	/home/martin/go/bin/staticcheck	(version: v0.6.1 built with go: go1.24.0)

## Go env

Workspace Folder (vscode-go-debug-test-output): /home/martin/Projects/vscode-go-debug-test-output

	AR='ar'
	CC='gcc'
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_ENABLED='1'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	CXX='g++'
	GCCGO='gccgo'
	GO111MODULE=''
	GOAMD64='v1'
	GOARCH='amd64'
	GOAUTH='netrc'
	GOBIN=''
	GOCACHE='/home/martin/.cache/go-build'
	GOCACHEPROG=''
	GODEBUG=''
	GOENV='/home/martin/.config/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFIPS140='off'
	GOFLAGS=''
	GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1075938469=/tmp/go-build -gno-record-gcc-switches'
	GOHOSTARCH='amd64'
	GOHOSTOS='linux'
	GOINSECURE=''
	GOMOD='/home/martin/Projects/vscode-go-debug-test-output/go.mod'
	GOMODCACHE='/home/martin/go/pkg/mod'
	GONOPROXY='<REDACTED>'
	GONOSUMDB='<REDACTED>/*'
	GOOS='linux'
	GOPATH='/home/martin/go'
	GOPRIVATE='<REDACTED>'
	GOPROXY='<REDACTED>'
	GOROOT='/usr/local/go'
	GOSUMDB='sum.golang.org'
	GOTELEMETRY='local'
	GOTELEMETRYDIR='/home/martin/.config/go/telemetry'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
	GOVCS=''
	GOVERSION='go1.24.4'
	GOWORK=''
	PKG_CONFIG='pkg-config'

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.goroot": "/usr/local/go",

Describe the bug

When I debug a test that logs output using t.Log, the log output is not visible anywhere until the test finishes.

Example test:

func TestMy(t *testing.T) {
	t.Log("some output " + time.Now().String())

	time.Sleep(1000) // breakpoint here
	t.Fail()
}

I expected to see t.Log output during debugging of the test while I set a breakpoint on the line with the sleep in the example. But the test output is not visible anywhere.

In my case the real test outputs connection information for connecting to the database instance started for the test case using testcontainers-go.

I tried adding

{
    "go.testFlags": [
        "-v"
    ]
}

to project's settings.json, but this did not help.

Also the Test Results tab show the result of the previous test run, which is confusing.

Steps to reproduce the behavior:

  1. Go to the Go file with the test
  2. Add a breakpoint after t.Log() call
  3. Click on Debug test in the line above the test function in the code editor
  4. Run the program until the breakpoint
  5. Look for the output of t.Log() from the debug session, but it is not visible anywhere. The output is visible only after the test finishes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions