diff options
| author | Shulhan <ms@kilabit.info> | 2018-09-08 02:34:21 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-09-08 02:34:21 +0700 |
| commit | 7715649d03ff004eb306ba4082eeefef7a6dd49c (patch) | |
| tree | b62a8cbc29fc50b9b68d2999cd4d363f064530f4 /lib/bytes/bytes.go | |
| parent | 210f1d0bafeedb148c18ee63e2571fbda66469d2 (diff) | |
| download | pakakeh.go-7715649d03ff004eb306ba4082eeefef7a6dd49c.tar.xz | |
lib/bytes: add function to write uint32
Diffstat (limited to 'lib/bytes/bytes.go')
| -rw-r--r-- | lib/bytes/bytes.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go index 5fdff819..84b1d309 100644 --- a/lib/bytes/bytes.go +++ b/lib/bytes/bytes.go @@ -84,6 +84,16 @@ func WriteUint16(data *[]byte, x uint, v uint16) { } // +// WriteUint32 into slice of byte. +// +func WriteUint32(data *[]byte, x uint, v uint32) { + (*data)[x] = byte(v >> 24) + (*data)[x+1] = byte(v >> 16) + (*data)[x+2] = byte(v >> 8) + (*data)[x+3] = byte(v) +} + +// // AppendInt16 into slice of byte. // func AppendInt16(data *[]byte, v int16) { |
