[[+content_image]]
T
T
to_east2019-07-26 11:40:03
go
to_east, 2019-07-26 11:40:03

Convert type []byte to [32]byte?

The input is a variable in the []byte type, then this variable is used as a key in the dictionary|slice
map[[32]byte]string with a fixed length of 32 bytes.
If it doesn't make it difficult, please provide several options for converting.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
Sergey Tikhonov, 2019-07-26
@to_east

https://stackoverflow.com/questions/30285680/how-t...
copy(dst_array[:], src_slice)

A
Andrey Tsvetkov, 2019-07-29
@yellow79

Can be converted using "black magic" unsafe , but be careful

func b2arr32(b []byte) [32]byte {
  return *(*[32]byte)(unsafe.Pointer(&b))
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question