delve icon indicating copy to clipboard operation
delve copied to clipboard

Unable to convert newtypes of slices to the primitive slice

Open SOF3 opened this issue 4 months ago • 0 comments

package main

type Message []byte

func main() {
        var x Message = []byte("abc")
        println([]byte(x)) // line 7
}
(dlv) c main.go:7
(dlv) p []byte(x)
Command failed: can not convert "x" to []uint8

However, surprisingly, p string(x) prints "abc" correctly.

SOF3 avatar Jun 27 '25 02:06 SOF3