Convert array to slice in Go
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This seems like it would be a fairly common thing and abundant examples across the interwebs, but I can't seem to find an example of how to convert an [32]byte to []byte . I have a function that I call from an external lib that returns an array func Foo() [32]byte {...} I then need to pass that result to a different function for further processing. func Bar(b []byte) { ... } Unforunately, if I try to call d := Foo() Bar(d) I get cannot convert d (type [32]byte) to type []byte Doing []byte(d) isn't much better. How do I do this, especially