ziutek/mymysql — Issue #7: question about encode&decode
Author: lewgun
Created: 2012-02-12 04:26:23+00:00
State: open

func DecodeU24(buf []byte) uint32 {
return (uint32(buf[2])<<8|uint32(buf[1]))<<8 | uint32(buf[0])
}

func EncodeU24(val uint32) []byte {
return []byte{byte(val), byte(val >> 8), byte(val >> 16)}
}

why the DecodeU24's impl is not:

func DecodeU24(buf []byte) uint32 {
return (uint32(buf[2])<<16|uint32(buf[1]))<<8 | uint32(buf[0])
}