Skip to content

Wrong handling of string([]byte) ? #4072

@thockin

Description

@thockin

I have a variable which is []byte:

(dlv) p p.output
[]uint8 len: 26, cap: 16384, [116,121,112,101,...+22 more]

I want to see it as a string:

(dlv) p string(p.output)
"type T struct {\f\f\t�fldcom�...+-4 more"

First - why so short? I have max-array-values = 4 and max-string-len = 256. This is neither of those.

Second: What does +-4 mean - At first I thought it was just 4, but:

(dlv) p string(p.output[8:])
"truct {\f\f\t�fldcom�...+-4 more"

??? I can only guess those mystery characters are screwing something up? Here's raw data:

(dlv) p p.output[0:26]
[]uint8 len: 26, cap: 16384, [116,121,112,101,32,84,32,115,116,114,117,99,116,32,123,12,12,9,255,102,108,100,99,111,109,255]

My environment:

$ dlv version
Delve Debugger
Version: 1.25.0
Build: $Id: e323af07680631b9cbdcc9d02e0a37891d12d972 $
$ go version
go version go1.24.1 linux/amd64
$ uname -a
Linux thockin-glaptop4 6.12.27-1rodete1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.27-1rodete1 (2025-05-19) x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions