Convert array to slice in Go

后端 未结 4 645
盖世英雄少女心
盖世英雄少女心 2020-12-07 18:40

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

4条回答
  •  清歌不尽
    2020-12-07 18:54

    This will do the trick:

    slice := array[0:len(array)]
    

    Also avoids copying the underlying buffer.

提交回复
热议问题