Trick is knowing the compiler can optimize string(b) away. 

const z8 = "\x00\x00\x00\x00\x00\x00\x00\x00"
const z64 = z8 + z8 + z8 + z8 + z8 + z8 + z8 + z8

if string(b64) == z64 {

}

Ren


On Saturday, 16 November 2019 03:32:32 UTC, Gert wrote:
>
> Is it possible to write this without creating a separate var b64 first? 
> Basically just write it in one line?
>
> var b64 [64]byte // 64 zero bytes
> if bytes.Equal(b64[:], x) {}
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c0479f85-6625-46b2-a748-423866a4028b%40googlegroups.com.

Reply via email to